Home > DeveloperSection > Forums > How can I Find Gridview in a listview using C#?
Simons Hood
Simons Hood

Total Post:70

Posted on    October-22-2013 3:46 AM

 C# C# 

 1 Reply(s)
 1582  View(s)
Rate this:

I have a gridview in template field of listview. I got gridview if i use the following line of code

protected void listView_ItemDataBound(object sender, ListViewItemEventArgs e)
   if (e.Item.ItemType == ListViewItemType.DataItem)
        ListViewDataItem itemList = (ListViewDataItem)e.Item;
        GridView grdView = (GridView) itemList.FindControl("gridView");

I want to make this gridview editable and I don't know how it done please help me out.!!!

Royce Roy
Royce Roy

Total Post:149

Posted on    October-22-2013 4:04 AM

Hey  Samuel!
Use Below line of code: -
GridView grdView = (GridView)item.FindControl("gridView");
DataTable dataTable = new DataTable();
DataRow dataRow = dataTable.NewRow();
dataRow["Columnname"] = "Wellcome";
grdView.DataSource = dataTable; 

Modified On Apr-05-2016 03:26:45 AM

Don't want to miss updates? Please click the below button!

Follow MindStick