Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > DropDownList template column in DataGrid

Reply
Thread Tools

DropDownList template column in DataGrid

 
 
mg
Guest
Posts: n/a
 
      05-15-2004

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?
 
Reply With Quote
 
 
 
 
mg
Guest
Posts: n/a
 
      05-15-2004
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'
 
Reply With Quote
 
 
 
 
JonathanVerrier
Guest
Posts: n/a
 
      05-17-2004
Use the on itemDataBound event and filter out by checking for
e.Item.Type == ListItemType.EditItem
regards jonathan

"mg" wrote:

>
> I have a DataGrid (WebForm - C#) that has a template column that contains a dropdownlist named "DdlTest" :
>
> In DataGrid1_UpdateCommand, the line
>
> DropDownList ddlTest = (DropDownList) e.Item.FindControl("DdlTest");
>
> enables me to work with ddlTest - with, for example, ddlTest.SelectedValue
>
> 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?
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to know if a datagrid column is a template column? Dexter ASP .Net 1 01-18-2005 01:45 PM
how do i access a dropdownlists selected value in a datagrid edititemtemplate column from the selectedindexchanged event of another dropdownlist in a datagrid edititemtemplate column Dave M ASP .Net Datagrid Control 0 12-14-2004 11:53 AM
DropDownList template column in DataGrid =?Utf-8?B?bWc=?= ASP .Net 3 05-17-2004 01:58 PM
Re: DataGrid with a template column which contains a databound dropdownlist jm ASP .Net 0 05-14-2004 10:22 PM
How to Bind a DropDownList control to a DataGrid in Template Column? Jeff Petter ASP .Net Datagrid Control 1 10-05-2003 03:29 PM



Advertisments