DropDownList template column in DataGrid

Discussion in 'ASP .Net Web Controls' started by mg, May 15, 2004.

  1. mg

    mg Guest

    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?
     
    mg, May 15, 2004
    #1
    1. Advertising

  2. mg

    mg Guest

    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'
     
    mg, May 15, 2004
    #2
    1. Advertising

  3. 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?
    >
     
    JonathanVerrier, May 17, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. jm
    Replies:
    0
    Views:
    636
  2. =?Utf-8?B?bWc=?=

    DropDownList template column in DataGrid

    =?Utf-8?B?bWc=?=, May 15, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    6,279
  3. Dexter
    Replies:
    1
    Views:
    425
    Eliyahu Goldin
    Jan 18, 2005
  4. Ken Varn
    Replies:
    1
    Views:
    983
    Ken Varn
    Aug 19, 2005
  5. Jeff Petter

    How to Bind a DropDownList control to a DataGrid in Template Column?

    Jeff Petter, Oct 3, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    291
Loading...

Share This Page