Access to DropDownList in a DataGrid from Page_Load

Discussion in 'ASP .Net' started by =?Utf-8?B?Z2xlbm4=?=, Apr 25, 2006.

  1. Hi folks,

    Page_Load has the following definition:
    Sub Page_Load(sender as Object, e as EventArgs)

    As such, we are unable to instantiate a control that is inside a DataGrid
    since
    the e parameter is an EventArgs and not a DataGridCommandEventArgs type.

    If I have a ddl and I want to load items automatically as the page loads,
    how can I access the control from Page_Load.

    If the ddl was not in a DataGrid, I could simply write:
    Dim ddl as DropDownList = e.Item.Cells(1).FindControl("ddl")

    but this does not work when the ddl is inside a DataGrid.

    Thanks for any replies,
    glenn
     
    =?Utf-8?B?Z2xlbm4=?=, Apr 25, 2006
    #1
    1. Advertising

  2. If the DataGrid is on the page then you can just use
    Dim ddl as DropDownList = MyDataGridID.FindControl("ddlD")

    ddl should now be a reference to the ddl within the datagrid. If the dll
    was not in a datagrid you could just reference it by it's ID within the page
    load and all other event handlers.

    "glenn" wrote:

    > Hi folks,
    >
    > Page_Load has the following definition:
    > Sub Page_Load(sender as Object, e as EventArgs)
    >
    > As such, we are unable to instantiate a control that is inside a DataGrid
    > since
    > the e parameter is an EventArgs and not a DataGridCommandEventArgs type.
    >
    > If I have a ddl and I want to load items automatically as the page loads,
    > how can I access the control from Page_Load.
    >
    > If the ddl was not in a DataGrid, I could simply write:
    > Dim ddl as DropDownList = e.Item.Cells(1).FindControl("ddl")
    >
    > but this does not work when the ddl is inside a DataGrid.
    >
    > Thanks for any replies,
    > glenn
    >
     
    =?Utf-8?B?Y2xpY2tvbg==?=, Apr 25, 2006
    #2
    1. Advertising

  3. =?Utf-8?B?Z2xlbm4=?=

    Jeff Dillon Guest

    Add a UNION statement to your SQL, then you don't have to bother with this.
    You can combine "auto" load items and databound items in your ddl. We do it
    here all the time. Save yourself a LOT of time.

    "glenn" <> wrote in message
    news:...
    > Hi folks,
    >
    > Page_Load has the following definition:
    > Sub Page_Load(sender as Object, e as EventArgs)
    >
    > As such, we are unable to instantiate a control that is inside a DataGrid
    > since
    > the e parameter is an EventArgs and not a DataGridCommandEventArgs type.
    >
    > If I have a ddl and I want to load items automatically as the page loads,
    > how can I access the control from Page_Load.
    >
    > If the ddl was not in a DataGrid, I could simply write:
    > Dim ddl as DropDownList = e.Item.Cells(1).FindControl("ddl")
    >
    > but this does not work when the ddl is inside a DataGrid.
    >
    > Thanks for any replies,
    > glenn
    >
     
    Jeff Dillon, Apr 25, 2006
    #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. bminder
    Replies:
    1
    Views:
    2,177
    nfedin
    Feb 23, 2004
  2. z. f.
    Replies:
    0
    Views:
    563
    z. f.
    Oct 19, 2004
  3. Shapper
    Replies:
    1
    Views:
    481
  4. rockdale
    Replies:
    1
    Views:
    661
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Nov 16, 2006
  5. Fredrik

    How do access a datagrid control in Page_load

    Fredrik, Dec 17, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    102
    Fredrik
    Dec 17, 2003
Loading...

Share This Page