I was using Gridview for a while now and I have noticed that its very easy to create a simple table and populate it with date f.e.
ID Name Surename Phone .....
1 Tom Tomtom 111122233
2 Vic VicVic 21231231
3 Rik RikRik 123545343
So here we have a simple gridview with three records, every record is in one line!
What I need is to put one record info in three lines like here:
ID Name Surename Phone .....
/ 1 Tom Tomtom 111122233
record1 { Additional info: blablabla
\ More info: xxxxx
/ 2 Vic VicVic 21231231
record2 { Additional info: blablabla
\ More info: xxxxx
/ 3 Rik RikRik 123545343
record3 { Additional info: blablabla
\ More info: xxxxx
So here we have a Gridview and here we show One record’s info in three lines…So how to do this?
I was using this code to populate my gridview when I have an Object of data but this works only with a single lines of records
private void grdMyGrid_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
MyObject ObjectEl = (MyObject)e.Row.DataItem;
e.Row.Cells[0].Text = ObjectEl.ID.ToString();
e.Row.Cells[1].Text = ObjectEl.Name.ToString();
e.Row.Cells[2].Text = ObjectEl.Surename.ToString();
LinkButton lbtConfigure = (LinkButton)e.Row.Cells[3].FindControl("lbtConfigure");
lbtConfigure.CommandArgument = Convert.ToString(ObjectEl.ID);
}
}
Templating rows like this is possible in a gridview, but the listview control is much better suited to this type of data.
Take a look here, this will get you started.
http://weblogs.asp.net/scottgu/archive/2007/08/10/the-asp-listview-control-part-1-building-a-product-listing-page-with-clean-css-ui.aspx