473,440 Members | 1,756 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,440 software developers and data experts.

DataGrid appending to my ItemTemplate IDs?

Hi everyone,

I'm using a DataGrid on one of my web pages and within it I have an
ItemTemplate containing a DropDownList. The relevant section looks like
this:

<asp:datagrid id="DataGrid1" runat="server">
........
<Columns>
<asp:TemplateColumn HeaderText="Division">
<ItemTemplate>
<asp:DropDownList runat="server" id="Dropdownlist1"
DataTextField="Name" DataValueField="DepartmentID" />
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
........

In the final HTML output my DropDownList items wind up as <select> tags
with names like "DataGrid1:_ctl2:Dropdownlist1." Even if I change the ID
values in my code-behind file (looping through all the DropDowns in the
DataGrid) the DataGrid still prepends to the ID-- the final IDs now read
something like "DataGrid1:_ctl2:DropDown3"

I'm not sure how to handle this. I read the values of these DropDowns
after posting the page, but if the DataGrid adds its own information to the
ID values then I'm likely to miss them or get the names wrong when I call
Request.Form[...]. And what if I add, say, a label to my DataGrid? Would
it change the prepended ID text on the other controls embedded in the
DataGrid?

I'd like to make sure my embedded controls at least consistently named.
Is it guaranteed that the DataGrids will always prepend the same information
to the IDs (<DataGrid Name>:_ctl<count>), or am I going to get in trouble
with that assumption?
Nov 19 '05 #1
0 865

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

Similar topics

0
by: shamila | last post by:
</asp:label><asp:datagrid id="DataGrid3" runat="server" cssclass="DataGrid" showfooter="True" onupdatecommand="DataGrid3_Update"ondeletecommand="DataGrid3_Delete" oneditcommand="DataGrid3_Edit"...
3
by: Kevin Pedersen | last post by:
Hello, I am using an editable datagrid. After I save the changes the datagrid shows the old values. I've read the posts about the Page_Load and not binding the datagrid each time. The SQL that...
7
by: localhost | last post by:
A DataGrid with shows a label in one of the columns when in view mode. When in edit mode, I want to show a dropdown, and have the default selection set to what the textbox used to be. Right now...
1
by: Rick | last post by:
Hello all, I hope all is well with you. I am having a seriously difficult time with this problem. Allow me to set up the problem. I have a System.Web.UI.Page with the following controls...
9
by: tshad | last post by:
How do I find (and set) a couple of labels in the Footer after a DataGrid is filled? I have a bunch of DataGrids that get displayed nested inside a DataList. The datagrid looks like: ...
2
by: Luis Esteban Valencia Muņoz | last post by:
I have a datagrid that displays editable text fields (2 different price fields) and a checkbox in every row. It has a "SaveChanges" button at the bottom, which, when pressed, looks at every...
0
by: Wyatt70 | last post by:
I'm attempting to implement a javascript popup calendar in a DataGrid. The calendar will be used to insert a date into a textbox. I keep getting a "System.NullReferenceException: Object reference...
1
by: Mike P | last post by:
I am populating a drop down column in a datagrid on page load. Here is my code : <asp:TemplateColumn> <ItemTemplate> <asp:DropDownList ID="ddlUserName" Font-Name="Verdana" Font-Size="8pt"...
2
by: Charleees | last post by:
Hi all, I have a DataGrid with Template Columns..... There are LAbels,Linkbuttons in the Single Row.. I have to set the Constant Column width for those Template Columns in Grid... Wat...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
1
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...
0
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.