Hi I am trying to get the values from dropdown list but everytime it selects the default
value
asp code:
<asp:TemplateField HeaderText="Customer Id" sortexpression="cust_id">
<EditItemTemplate>
<asp:DropDownList ID="ddl1" runat ="server" OnLoad="ddl1_load" ></asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblc" runat="server" CssClass="label" Text='<%#Eval("cust_id")%>'></asp:Label>
</ItemTemplate>
<HeaderStyle BorderStyle="Inset" Font-Bold="True" Font-Underline="True" ForeColor="Teal" />
</asp:TemplateField>
code behind:
Protected Sub ddl1_load(ByVal sender As Object, ByVal e As EventArgs)
Dim con As New SqlConnection
con.ConnectionString = ""
Dim da As New SqlDataAdapter("select custId from CustomerRegister", con)
Dim dt As New DataTable()
da.Fill(dt)
Dim ddl As DropDownList = DirectCast(sender, DropDownList)
ddl.DataSource = dt
ddl.DataTextField = "custId"
ddl.DataValueField = "custId"
ddl.DataBind()
End Sub