This is a migrated thread and some comments may be shown as answers.

How to Generate Insert, Edit Control on runtime

1 Answer 71 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Vivek Tyagi
Top achievements
Rank 1
Vivek Tyagi asked on 25 Oct 2011, 06:51 AM
hello this is Vivek here
How can i generate Runtime control in edit or insert, like Binded Dropdown-list etc...

Regards Vivek

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 25 Oct 2011, 07:17 AM
Hello Vivek,

I suppose you want to add a DropDownList in edit mode. If that is the requirement, then here is the sample code that I tried which worked as expected.
C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
   if (e.Item is GridEditableItem && e.Item.IsInEditMode)
   {
      GridEditableItem item = (GridEditableItem)e.Item;
      TableCell cell = item["ColumnUniqueName"];
      DropDownList list = new DropDownList();
      list.ID = "ddl";
      list.DataSourceID = "SqlDataSource1";
      list.DataTextField = "EmployeeID";
      list.DataValueField = "EmployeeID";
      cell.Controls.Add(list);
   }
}

Thanks,
Shinu.
Tags
Grid
Asked by
Vivek Tyagi
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or