473,657 Members | 2,932 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Access to DropDownList in a DataGrid from Page_Load

Hi folks,

Page_Load has the following definition:
Sub Page_Load(sende r 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 DataGridCommand EventArgs 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("d dl")

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

Thanks for any replies,
glenn

Apr 25 '06 #1
2 1869
If the DataGrid is on the page then you can just use
Dim ddl as DropDownList = MyDataGridID.Fi ndControl("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(sende r 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 DataGridCommand EventArgs 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("d dl")

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***@discussi ons.microsoft.c om> wrote in message
news:E1******** *************** ***********@mic rosoft.com...
Hi folks,

Page_Load has the following definition:
Sub Page_Load(sende r 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 DataGridCommand EventArgs 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("d dl")

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
2233
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. I get the following message for this code but I suspect that the " UltraWebGrid1.Rows.Cells.Value = ddlGeography;" is not how you bind the dropdownlist control to the grid. ERROR: "The type 'System.Web.UI.WebControls.DropDownList' must be...
2
17002
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 the columns of the data grid contains a DropDownlist. I managed to create this datagrid control as follows.
0
4786
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 TemplateColumn with a DropDownList (DDL) in the FooterItemTemplate that is populated in the Page_Load event using a Sub Routine as the DataSource of the DDL. The FooterItemTemplate's DDL populates as expected when the DataGrid's DataBind method is called. ...
4
1545
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 displays a datagrid with the same data, now this does work so i know the data is there but the dropdownlist is empty. If anyone could show me where i'm going wrong i would be very thankful. Here is the code i am using:
4
2008
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, when the datagrid enters it's own OnPreRender, the selected index has reverted to zero. I created a debug version of the dropdown list which inherited from dropdownlist and overrode the selected index property to trace.write whenever it was...
0
2270
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 want to use this 1st DDList to populate the 2nd DDList via the SelectedIndexChange Event. So far so good. all works up to this point. The next thing I'm trying to do is to use the 2nd DDList value in a queery to populate the Datagrid also...
1
1557
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 dropdownlist should be filled with the values in field NAME from the same dataset used in the datagrid. The default value of each dropdownlist should be the value of NAME by
2
7310
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 SelectedIndexChanged event. I also have another TemplateColumn, with a RequiredFieldValidator that validates a TextBox in the column. It all looks like this, in broad strokes:
0
973
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? It works if i find a control in an itemcommand, but not in Page_load or other functions. Here's the code: Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim ddlbox As...
0
8820
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8718
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8499
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8601
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6162
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5630
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4150
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4300
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1937
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.