J
Jim Bancroft
Hi,
I have a DataGrid that contains an ItemTemplate. Within the
ItemTemplate I have a DropDownList. The relevant code looks like this:
<asp:datagrid id="DataGrid1" runat="server">
................
<Columns>
<asp:TemplateColumn HeaderText="Division">
<ItemTemplate>
<aspropDownList runat="server" id="Dropdownlist1"
DataTextField="Name" DataValueField="DepartmentID" />
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
..............................
When the page runs my DropDownList morphs into an html <select> tag, as I'd
expect. However the ID of the tag is a little strange: what happens is the
DataGrid prepends some information to it, so that instead of <select
ID='Dropdownlist1'..." I get "<select
ID='DataGrid1:_ctl2ropdownlist1'...."
I understand why the DataGrid does this --not good having a batch <select>
tags on the page with the same ID-- but I'm worried about how consistent the
names will be. For instance, if I add additional ItemTemplates (with other
controls) to this DataGrid will my existing DropDownList IDs change? I read
these <select> values on postback, using the Request object, and if their
IDs change unexpectedly I'll be hurting....I just want to see what my risks
are. Thanks for your advice.
-Jim
I have a DataGrid that contains an ItemTemplate. Within the
ItemTemplate I have a DropDownList. The relevant code looks like this:
<asp:datagrid id="DataGrid1" runat="server">
................
<Columns>
<asp:TemplateColumn HeaderText="Division">
<ItemTemplate>
<aspropDownList runat="server" id="Dropdownlist1"
DataTextField="Name" DataValueField="DepartmentID" />
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
..............................
When the page runs my DropDownList morphs into an html <select> tag, as I'd
expect. However the ID of the tag is a little strange: what happens is the
DataGrid prepends some information to it, so that instead of <select
ID='Dropdownlist1'..." I get "<select
ID='DataGrid1:_ctl2ropdownlist1'...."
I understand why the DataGrid does this --not good having a batch <select>
tags on the page with the same ID-- but I'm worried about how consistent the
names will be. For instance, if I add additional ItemTemplates (with other
controls) to this DataGrid will my existing DropDownList IDs change? I read
these <select> values on postback, using the Request object, and if their
IDs change unexpectedly I'll be hurting....I just want to see what my risks
are. Thanks for your advice.
-Jim