c# - populate the values of multiple rows in single row in gridview -


I am trying to populate the values ​​of multiple rows in a single line in gridview, such as the roundabout of code behind the page Fast in section:

  Col1 Col6 a 1 a 2 a 3 a 4   

I have changed it

  Col1 Col6 a 1 2 3 4   

Now I want to get it, any help please?

  Col1 Col6 a 1 2 3 4   

What's wrong with the code given below?

  if (e.ro. seals [0]. Text == "" & amp; e.Row.Cells [5] text! = "") {For (int one = 0; a & lt; GridView1.Rows.Count; a ++) {string s = GridView1.Rows [a] .cel [5]. Text; GridView1.Rows [e.Row.RowIndex - 1] .cell [5]. Text + = s; }}   

What am I doing wrong, anybody? Cells [0] have call 1 cell [5] col6

I think you are coming from the wrong direction. Think of GridView as your display, you need to organize the data before sending it to GridView I'm not sure what your data is like, but You can repeat through your data and create new records which are essentially a group and can enter all the data you need in the same line that you can dataset.

The problem with using RowDatabound (or any database method) is that you are working with data based on a row, which you do not want to do , Because you can not 'see' other rows in context.

To organize the data, you can use the following snippet to get a comma separated list for each call 1 value:

  string commaValues = String (",", (Choose your list. Where (i => i.Col1.Equals (some value)) (s = & gt; s.YourStringValue)). ToArray ());   

This will produce a comma-delimited string for a given value ( someValue example):

  Use above to create an  list  of commaValues ​​= "1, 2,3,4,5"   

objects so that you can directly tie it directly Able to Example: Class NewObject {Get Public String ID {Get; Set; } Public string text {get; Set; }} List & new; Object & gt; Systematic data = new list & lt; NewObject & gt; (); // Organize your grid data DataSource = arrangedData; YourGrid.DataBind ();

Comments