Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Access to DropDownList in a DataGrid from Page_Load

Reply
Thread Tools

Access to DropDownList in a DataGrid from Page_Load

 
 
=?Utf-8?B?Z2xlbm4=?=
Guest
Posts: n/a
 
      04-25-2006
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

 
Reply With Quote
 
 
 
 
=?Utf-8?B?Y2xpY2tvbg==?=
Guest
Posts: n/a
 
      04-25-2006
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
>

 
Reply With Quote
 
 
 
 
Jeff Dillon
Guest
Posts: n/a
 
      04-25-2006
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:E1F0EAC4-F5B0-4EF1-A845-...
> 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
>



 
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
Materpage page_load event fired after content page_load? rockdale ASP .Net 1 11-16-2006 06:59 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
in VB.NET Page_load of a base class called after the derived class Page_load ? z. f. ASP .Net 0 10-19-2004 12:01 PM
Why does page_load fire twice when inheriting from a common overridable Page_Load bminder ASP .Net 1 02-23-2004 08:54 PM
How do access a datagrid control in Page_load Fredrik ASP .Net Datagrid Control 0 12-17-2003 12:25 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57