updating value from selectedvalue of DD is null


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>
<asp:parameter Name="wa" Type="String" />
<asp:parameter Name="operator" Type="String" />
</UpdateParameters>

<asp:TemplateField HeaderText="wa">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server">
</asp:DropDownList>
</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
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top