Click here to Skip to main content
15,886,578 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
How can I put more than 1 item of datarow(from table of database) in each row of gridview or is it posible to do that?.

And this is my sample pic..http://image.free.in.th/show.php?id=576c4ca3ad11a87887a249b9c01f28e7[^]
Posted
Updated 6-Mar-11 21:33pm
v2

You need to get the data source from your gridview and store the data source in a data table.
Add your new rows to the data table.
Set the data source of the grid view to the modified data table and bind your data.

DataTable dt = (DataTable)GridView1.DataSource;
object[] obj = new object[4];
obj[0] = "Column 1";
obj[1] = "Column 2";
obj[2] = "Column 4";
obj[3] = "Column 3";
dt.Rows.Add(obj);
GridView1.DataSource = dt;
GridView1.DataBind();
 
Share this answer
 
v2
Comments
jack_th 10-Mar-11 2:31am    
Thanks sir!
Ryan Zahra 10-Mar-11 2:32am    
You're welcome :)
you should use DataList and change columns to 4.

<asp:DataList ID="DataList1" runat="server" RepeatColumns="4" GridLines="Both" >
 
Share this answer
 
v2
Comments
jack_th 10-Mar-11 2:32am    
Thanks, sir!
pankajupadhyay29 10-Mar-11 2:56am    
your welcome

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900