M
Mark
Hi,
There are two dropdownlists in two EditItemTemplates of a gridview. They are
populated programmatically (see code below). This works.
But now, the selected value of the first ddl (dropdownlist1) takes always
the selected value of the second ddl (dropdownlist2) , and the new value
chosen for update in the first ddl is also always the value chosen (or
selectedvalue if not chosen) of the second ddl. It seems that the second ddl
overrules the first one. In normal mode, the values of both ddl are rendered
correctly.
I can't find any reason for that, and the only way i found is to populate
one of the ddl manually (in aspx file). But that is fastidious, isn't it?)
Thanks for help
Mark
Here the code in aspx file:
<asp:TemplateField HeaderText="min" SortExpression="min">
<EditItemTemplate>
<aspropDownList ID="DropDownList1" runat="server" SelectedValue='<%#
Bind("min") %>'></aspropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("min") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="max" SortExpression="max">
<EditItemTemplate>
<aspropDownList ID="DropDownList2" runat="server" SelectedValue='<%#
Bind("max") %>'></aspropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("max") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
and here thet code-behind:
Protected Sub GridView1_RowCreated(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowCreated
If (e.Row.RowState And DataControlRowState.Edit) =
DataControlRowState.Edit Then
If e.Row.RowType = DataControlRowType.DataRow Then
Dim dd1, dd2 As DropDownList
Dim z As ListItem
Dim i As Integer
dd1 = e.Row.FindControl("dropdownlist1")
dd2 = e.Row.FindControl("dropdownlist2")
For i = 0 To 200
z = New ListItem(i, i)
dd1.Items.Add(z)
dd2.Items.Add(z)
Next
End If
End If
End Sub
There are two dropdownlists in two EditItemTemplates of a gridview. They are
populated programmatically (see code below). This works.
But now, the selected value of the first ddl (dropdownlist1) takes always
the selected value of the second ddl (dropdownlist2) , and the new value
chosen for update in the first ddl is also always the value chosen (or
selectedvalue if not chosen) of the second ddl. It seems that the second ddl
overrules the first one. In normal mode, the values of both ddl are rendered
correctly.
I can't find any reason for that, and the only way i found is to populate
one of the ddl manually (in aspx file). But that is fastidious, isn't it?)
Thanks for help
Mark
Here the code in aspx file:
<asp:TemplateField HeaderText="min" SortExpression="min">
<EditItemTemplate>
<aspropDownList ID="DropDownList1" runat="server" SelectedValue='<%#
Bind("min") %>'></aspropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("min") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="max" SortExpression="max">
<EditItemTemplate>
<aspropDownList ID="DropDownList2" runat="server" SelectedValue='<%#
Bind("max") %>'></aspropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("max") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
and here thet code-behind:
Protected Sub GridView1_RowCreated(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowCreated
If (e.Row.RowState And DataControlRowState.Edit) =
DataControlRowState.Edit Then
If e.Row.RowType = DataControlRowType.DataRow Then
Dim dd1, dd2 As DropDownList
Dim z As ListItem
Dim i As Integer
dd1 = e.Row.FindControl("dropdownlist1")
dd2 = e.Row.FindControl("dropdownlist2")
For i = 0 To 200
z = New ListItem(i, i)
dd1.Items.Add(z)
dd2.Items.Add(z)
Next
End If
End If
End Sub