DropDownList template column in DataGrid

M

mg

I have a DataGrid (WebForm - C#) that has a template column that contains a dropdownlist named "DdlTest"

In DataGrid1_UpdateCommand, the lin

DropDownList ddlTest = (DropDownList) e.Item.FindControl("DdlTest")

enables me to work with ddlTest - with, for example, ddlTest.SelectedValu

However, in DataGrid1_EditCommand, ddlTest.SelectedValue returns "Object reference not set to an instance of an object.

Is it possible to work with DdlTest in DataGrid1_EditCommand?
 
M

mg

My goal is to have the dropdownlist in the template column of a datagrid come up with the last saved value, when the user clicks 'edit'
 
J

JonathanVerrier

Use the on itemDataBound event and filter out by checking for
e.Item.Type == ListItemType.EditItem
regards jonathan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top