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

Grid inplace editing populate dropdowns with db class

3 Answers 76 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Timothy Stanton
Top achievements
Rank 1
Timothy Stanton asked on 29 Nov 2011, 04:50 PM
Hello!   could you please direct me to a great example of how (on editing a row) to hook up a drop down on the row to a database class.  It can't be a static list on the page.  So far, I've not been able to find an example or figure this out on my own!

thanks in advance! Tim

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 30 Nov 2011, 06:52 AM
Hello Tim,

Try the following code snippet.
C#:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
 if (e.Item is GridEditableItem && e.Item.IsInEditMode)
 {
     GridEditableItem item = (GridEditableItem)e.Item;
     DropDownList ddl = (DropDownList)item.FindControl("ddl");
     ddl.DataValueField = "EmployeeID";
     ddl.DataValueField = "EmployeeID";
     ddl.DataSourceID = "SqlDataSource1";
 }
}

-Princy.
0
Timothy Stanton
Top achievements
Rank 1
answered on 30 Nov 2011, 08:58 PM
Princy - thanks.

So you have to populate the dropdown as the grid is bound? (per row?)    I had tried that code in the EditCommand of the grid, but the 'FindControl' returns a null value.

Interesting.  I may have to do this a different way. 
0
Princy
Top achievements
Rank 2
answered on 01 Dec 2011, 05:35 AM
Hello,

You can access controls in ItemDataBound event because controls are only bound during this event.

Thanks,
Princy.
Tags
Grid
Asked by
Timothy Stanton
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Timothy Stanton
Top achievements
Rank 1
Share this question
or