How can I Find Gridview in a listview using C#?

Total Post:70

Points:494
C# 
C#
 1963  View(s)
Ratings:
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.!!!

  1. Post:149

    Points:1043
    Re: How can I Find Gridview in a listview using C#?

    Hey  Samuel!
    Use Below line of code: -

    GridView grdView = (GridView)item.FindControl("gridView");
    
    DataTable dataTable = new DataTable();
    dt.Columns.Add("Columnname");
    DataRow dataRow = dataTable.NewRow();
    dataRow["Columnname"] = "Wellcome";
    dataTable.Rows.Add(dataRow);
    grdView.DataSource = dataTable;
    grdView.DataBind();

      Modified On Apr-03-2018 05:35:40 AM

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!