Listview
how to add grid view inside list view
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Abhishek JainRank #1,062 · 1.8K reputationPosted Aug 29, 2013, 3:54 AM EDT
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