473,396 Members | 1,816 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Access to DropDownList in a DataGrid from Page_Load

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

Apr 25 '06 #1
2 1862
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

Apr 25 '06 #2
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" <gl***@discussions.microsoft.com> wrote in message
news:E1**********************************@microsof t.com...
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

Apr 25 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: rmorvay | last post by:
I am trying to dynamically build a dropdownlist and bind it to a cell in a grid. I tried to utilize the following code but I am stuck at the point where I bind the dropdownlist to the grid cell. ...
2
by: Dominic | last post by:
Hi guys, I'm not sure if this question belongs to FAQ, but I couldn't find a concrete answer. I created a Datagrid control using ItemTemplate, but it's NOT a in-place editing datagrid. One of...
0
by: Shane O. Pinnell | last post by:
I am sure this has come up before, but I haven't been able to find an answer as of yet. That said, any help is definitely appreciated! I have a datagrid populated from a dataset. I have a...
4
by: Iain Kirk | last post by:
Being a bit of a novice any help or pointers would be appreciated. I am building a web page that populates a DropDowList from a table in SQL, for testing purposes i have a simple page that...
4
by: Mark Waser | last post by:
I've discovered a very odd bug when attempting to put a dropdown list in a datagrid. In the page PreRender step, the selected index of the datagrid is successfully set during databinding. Yet,...
0
by: Tand35006 | last post by:
Hi, I hope some one can help with this. I have a basic webform with 2 DropDownLists and a single DataGrid. What I am trying to do is populate the first DDList from a dataset on Form_Load. I then...
1
by: Miguel Dias Moura | last post by:
Hello, I have two questions concerning Asp:DropDownList 1. How to fill a DropDownList from runtime and set its default item? 2. How do use a DropDownList in each datagrid record? All...
2
by: Steve Hershoff | last post by:
Hi everyone, I have a DataGrid with several TemplateColumns. One of these columns has an EditItemTemplate that contains an ASP.Net DropDownList. I'm catching this DropDownList's...
0
by: henrychong | last post by:
Can someone help me. I want to find a dropdownlist control in a datagrid (named dgDestinations) and i want to make the dropdownlist visible in Page_load. How can i access the control in Page_load?...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.