listview
how to add grid view inside list view
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Abhishek JainPosted Aug 29, 2013, 7:54 AM
Here is the sample code for the same:
List
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
List
dummyList.Add(1);
dummyList.Add(2);
TestClass obj1 = new TestClass();
TestClass obj2 = new TestClass();
obj1.Id = 1;
obj1.Name = "Name1";
obj2.Id = 2;
obj2.Name = "Name1";
dummygrid.Add(obj1);
dummygrid.Add(obj2);
list.DataSource = dummyList;
list.DataBind();
}
}
protected void list_OnDataBound(object sender, ListViewItemEventArgs e)
{
if (e.Item.ItemType == ListViewItemType.DataItem)
{
GridView grid = (GridView)e.Item.FindControl("grid");
grid.DataSource = dummygrid;
grid.DataBind();
}
}
Note that the data is just the dummy data, you can create the data according to your need. and provide the data sources accordingly.
Hope it helps you in achieving this, if you still face some problem, please let me know may be i can provide you some more help