B
Ben
Hi,
With this code, when i click on Update button, the value updated of field
"wa" in the table is NULL.The update of the other field (not in a DD) works
good.
It seems that the selectedvalue of the dropdownlist (which exists, i tested
it with response.write) is not used as updating value.
Any idea why?
thanks
Ben
UpdateCommand="UPDATE [condition] SET [wa] = @wa, [operator] = @operator
WHERE [id] = @id">
<UpdateParameters>
<asparameter Name="wa" Type="String" />
<asparameter Name="operator" Type="String" />
</UpdateParameters>
<asp:TemplateField HeaderText="wa">
<EditItemTemplate>
<aspropDownList ID="DropDownList1" runat="server">
</aspropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("wa")
%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewRowEventArgs) Handles
GridView1.RowDataBound
If (e.Row.RowState And DataControlRowState.Edit) =
DataControlRowState.Edit Then
If e.Row.RowType = DataControlRowType.DataRow Then
Dim dd As DropDownList
Dim i As Integer
Dim z As ListItem
dd = e.Row.FindControl("DropDownList1")
For i = 1 To 20
z = New ListItem(i, i)
dd.Items.Add(z)
Next
dd.SelectedValue = DataBinder.Eval(e.Row.DataItem,
"wa").ToString()
Response.Write(dd.SelectedValue)
End If
End If
End Sub
With this code, when i click on Update button, the value updated of field
"wa" in the table is NULL.The update of the other field (not in a DD) works
good.
It seems that the selectedvalue of the dropdownlist (which exists, i tested
it with response.write) is not used as updating value.
Any idea why?
thanks
Ben
UpdateCommand="UPDATE [condition] SET [wa] = @wa, [operator] = @operator
WHERE [id] = @id">
<UpdateParameters>
<asparameter Name="wa" Type="String" />
<asparameter Name="operator" Type="String" />
</UpdateParameters>
<asp:TemplateField HeaderText="wa">
<EditItemTemplate>
<aspropDownList ID="DropDownList1" runat="server">
</aspropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("wa")
%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewRowEventArgs) Handles
GridView1.RowDataBound
If (e.Row.RowState And DataControlRowState.Edit) =
DataControlRowState.Edit Then
If e.Row.RowType = DataControlRowType.DataRow Then
Dim dd As DropDownList
Dim i As Integer
Dim z As ListItem
dd = e.Row.FindControl("DropDownList1")
For i = 1 To 20
z = New ListItem(i, i)
dd.Items.Add(z)
Next
dd.SelectedValue = DataBinder.Eval(e.Row.DataItem,
"wa").ToString()
Response.Write(dd.SelectedValue)
End If
End If
End Sub