FormView Paging Challenge: Get multiple rows out of one row using parsing.

I have a database which returns Articles, one row per Article.


Each article has multiple fields,

ID, Title, Subtitle, Summary, Text etc.

I return the row from an ObjectDataSource which uses a stored procedure on a SQL Box.

Inside the "TEXT" field, there is text -  [NEWPAGE] wherever a new page should start.

 eg. Content Content This is Content This is Content This is Content This is Content This is Content Content Content Content Content Content

This is Content  This is Content This is Content This is Content This is Content This is Content


This is Content  This is Content This is Content This is Content This is Content This is Content This is Content This is Content

I want to use the FormView's paging but it relies on multiple rows.  How can I take that one Row of data, parse the "text" field for [NEWPAGE] and return a dataset of multiple rows?

Perhaps i'm going about this wrong way, but has anyone got any ideas?

5/15/2007 10:23:23 PM 72751 articles. 3 followers. Follow

4 Replies

Similar Articles

[PageSpeed] 34

I'm thinking I didn't make the question clear enough, so I'm going to rewrite it.

Basically, for Paging to work in the FormView it needs to have a DataSource with more than one record (ie. One record / page)

Unfortunately, my dataSource returns ONE record, with the text [NEWPAGE] interspersed in the ArticleText field.

Is there a way, either in SQL or in the Data Object that I can make that one record into multiple records.

I know that means I have to parse for [NEWPAGE] and make three records, but I have no idea how I'm going to do that.


5/16/2007 5:34:49 AM


  I think there're many ways. If you like, you can use ObjectDataSouce and write the custom select method to get this record and split it into pieces and return a new DataTable or ArrayList. To get started, refer to this tutorial:

  You can also do this directly (in Page_Load, maybe) and bind the new DataTable or ArrayList to the FormView.

  Another totally different method is not to change the DataSource but write custom paging. You can add some LinkButtons and set their CommandName then handle the event in code behind. And in the First PreRender, you should change the appearance to envisible other fields.

If it doesn't help, please inform us.


Allen Chen
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
5/17/2007 10:36:35 AM

Thanks! I'm going to take a look at those solutions... for now, I was pulling the data into a datarow and I created a method in my utility class that take a datarow as input and outputs a table of multiple rows, based on the parsed data.


so my signature looks like this:

public DataTable (DataRow dr, String columnName, String parseKey)

This seemed to work, but I have to handle paging manually, in the pagechanging event.

Thanks for the reply, I'll post my results here to help the community.


5/20/2007 10:36:12 PM

Okay, so an update:

Here's what I did: 


  I have a method that returns a DataTable, I call it like this:
DataTable mySplitTable = getSplitTable(originalTableView.Table.Rows[0], "ArticleID", "ArticleText", "[NEWPAGE]");
 The getSplitTable requires the single row from the DataSource, The Primary Key, The fieldName you want to parse, and what you want to parse on.
    private DataTable getSplitTable(DataRow dr, string keyID, string columnName, string parseText)

        // make parseString UpperCase
        string[] stringSeparators = new string[] { parseText.ToUpper() };

        //Gets the Text you want to parse in passed field (columnName)
        String theText = dr[columnName].ToString();

        //replace all parseText in theText with UpperCase
	// This is a custom method to replace text.  In this case, I'm using it to replace any occurance of [newpage] with [NEWPAGE]
        theText = SiteUtil.Replace(theText, parseText, parseText.ToUpper());

        //Split Text and pass it to an array of pages
        String[] pages = theText.Split( stringSeparators, StringSplitOptions.RemoveEmptyEntries );

        // Copy the Table from the passed DataRow and put it into new table.
        DataTable splitTable = dr.Table.Clone();

        if (dr.IsNull(keyID))
		//return splitTable if it's null
            return splitTable;
            // Loop through the array of Strings (the split up Text) and set the columnName text 
            foreach (String page in pages)

                // define a new row in pagedTable
                DataRow newRow = splitTable.NewRow();

                //copy all the values from dr values Array
                newRow.ItemArray = dr.ItemArray;

                // write modified row to splitTable

        return splitTable;

6/22/2007 5:18:02 AM

Similar Artilces:

Add new controls to a gridview row; when editing that row using the edit row feature in the gridview control.
Hi all  I have a questions that looks hard / complex to me, and i know you can help me in this. Q {  I have row in a Gridview and i have an edit option to it. I press the edit button, to edit the values in that row and update data all the way back to the database. Now when i press the edit button, i want a drop down list to be displayed that contain values for a particular field in my grid view. (for now only plain text boxes appear.) } I hope you understand my question, all i need to do is replace the text box controls with a dropdown list when i am editing a row in ...

Gridview paging enabled. Has checkbox to select the row . If user select the checkbox on one page and move to 2nd page to select the rows there also to export the selected rows to excel. But doing so
HiI am using Gridview and that has paging enabled. Using checkbox to select the particular row of the gridview to export the selected rows to the excel . Everything is working fine except for one case.Let user selected the "check" box for, five rows which user would like to export to excel (two of rows on page 1 of results and 3 of them on page 2 of results), however it only exports the 3 row details from page 2, because it seems to de-select the 2 rows from page 1 when I move to page 2 and vice versa. The code i am using is as :protected void BtnExcel_Click(object sender, EventArg...

SQL: mutiple rows one column to multiple columns one row
In InfoMaker SQL can you take a table with multiple rows for the same key and take a column from the rows and create mutiple columns with one report line with the key(no duplicate keys) on a report? For example Table books (key) (book title) 123 misery 123 titanic 123 roots 456 war 456 1984 456 giant The report I need would look like this Key title1 title2 title 3 123 misery titanic roots 456 war 1984 giant Thanks in advance. -- Kaye Hendry HealthInsight ...

concatenate multiple rows in one row
i have a table below id    text1    text2 -------------------------------118   id12    text123 7118   4     retre 8118     3    erwetre    i need to convert the rows to columns in sql server 2000(pivot in 2005 but i dont want in 2005) to id  text1   text2            text1        text2   text1       &...

Combine Multiple Rows into One Row
I am having a problem joining multiple row values into a single row.I need the values to be displayed like:Values Merged     Value Equals123 - 127              2129                      2131                      2 Currently the values are displaying like this:Values Not Merged   &nb...

get the row element values using row index for dynamic dropdownlist using javascript
Friends,How to get the row element values using row index for dynamic dropdownlist using javascript ?Thanks in advance  I want creating dynamic dropdownlist  using javascript. I am working on deleting a row. function DeleteRow(r) { var i = r.parentNode.parentNode.rowIndex;document.getElementById("ctl_Contentmain_tbldynamic").deleteRow(i);var str = document.getElementByName("ddljobs");   alert(str); } Check out this. var str = document.getElementById('<%=ddljobs.ClientID%>');   Thanks,santosh_maharajaPlease mark as answer ...

How do i get one row if the resultset returned has no rows.
Hi I have couple of CTE's which i want to ultimately insert into a temp table... and based on my condition some of the CTE's return some rows and some dont... but i want to have the CTE return atleast one row if there is no data in it.. I have tried doing the following but i am not getting the desired output    ;with cte_rpt4 as (select '4' a,recd_dt as approve_dt, prov_no, prov_name, client_id, claim_mst_id, claim_adj_id, claim_dt, claim_amt, rpt4, (Select count(distinct(Claim_mst_Id)) as crpt4 from #temp1 where datediff(day,isnull(recd_dt,create_dt),isnull(c...

How can I use multiple DataKeyNames with one GridView and multiple DetailsView controls, all on the same page?
I've been struggling with this all day, and just spent 3 hours searching through forums but can't find an answer... I have 1 GridView control and 2 DetailsView controls, on the same page, and all are bound to my Access database. GridView1 contains TeamID and StatusID DetailsView1 correctly displays TeamID and TeamMemberName when a record is selected in GridView1. DetailsView2 should display StatusID and StatusDescription when a record is selected in GridView1, but it won't.  It appears to be picking up TeamID instead. I read something about trying: GridView.DataKeys(Index1...

Return single colum from multiple rows into one row?
Often in my apps I'll create a table in SQL to house different variables. I do this so that I don't end up with multiple tables just to store a list of phone types for example. What I mean is let's say I have a form that would store contact information one of the controls might be a phone number and then next to that I'd have a drop down that would list the different phone types like Phone, Mobile, Fax etc rather than hard coding a specific textbox for only phone or only the mobile number. This way the user can determine white type of contact number it is.  With th...

How to get the row index of a selected row in listview control
Can someone please tell me how to get the index of a selected row in a listview.  <ItemTemplate> <asp:LinkButton runat="server" class="linkButton" id="xxxxx" Text='<%#Eval("documenttype") %>' CommandName="OpenFile" CommandArgument='<%#Eval("DocumentKey") %>'></asp:LinkButton></ItemTemplate>what you have to do is, in itemcommand event of ListView, you have to get the value of row indexif(e.CommandName == "corrospondingcommaandname"){     &nb...

Net::LDAP::Control::Paged unexpected behavior using multiple paged searches against AD [SEC=UNCLASSIFIED]
------=_NextPart_000_003B_01CEEE7E.0BE685F0 Content-Type: multipart/related; boundary="----=_NextPart_001_003C_01CEEE7E.0BE685F0" ------=_NextPart_001_003C_01CEEE7E.0BE685F0 Content-Type: multipart/alternative; boundary="----=_NextPart_002_003D_01CEEE7E.0BE685F0" ------=_NextPart_002_003D_01CEEE7E.0BE685F0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit UNCLASSIFIED Hi . I am finding unexpected behaviour when using this control against our AD servers. I have tried this using 5.8 (perl-ldap 0.4...

How to read a dataset one row by one row?
I know you can use DataSet after close sql connection. I want to something after getting dataset, read from one row by one row, just like while Can I read dataset just like this? Thanks in advance! Justin Is this what you're looking for (from the Tips and Tricks Section of WierMCP/ - where to look first!Control Grouper - easily control properties for multiple controls with one control!Calendar Express - The Best HTML Calendar Generator on the web!(Please 'Mark as Answer&...

Using formview controls on one page...
Hi everyone, I am trying to use 2 formview controls with different SQLDataSources, for inserting data . I dont want to use them both but only one, depending on a selection from a dropdown list and using classic IF ELSE statements to display one or the other. The problem that I have is that when  I have 2 formview controls on the page it doesnt seem to do anything, but when  I only have one formview control it seems to work fine and inserting data. Any ideas on how to overcome this problem ? ...

Row ID of the newly inserted row FormView using AccessdataSource
How can I get the AccessDatasource Row ID of the newly inserted row when adding anew record to the database using a FormView Control on a web page?I've looked at the FormView_ItemInserted FormViewInsertedEventArgs but to noavail. can some one give me sample code for it thanks   Hi:   Please check out this article:   The idea is to use ViewState to store the id of newly inserted record. RegardsSincerely,Allen ChenMicrosoft Online Com...

Web resources about - FormView Paging Challenge: Get multiple rows out of one row using parsing. -

Resources last updated: 1/16/2016 12:38:05 AM