ninel
Active member
I have a dropdownlist box within a datagrid that is populated with values that come from a database.
What I need is....
When a user selects a different value in the dropdown , on the autopostback I need to update the database with that value and then re-display the datagrid with the dropdown having the new value from the database.
Here's my code so far:
VB.NET:This populates the dropdown within the datagrid.
I can't figure out in which event I need to capture the new dropdown value and then call the stored proc that updates the value in the database.
Can someone help me please?
Thanks,
Ninel
What I need is....
When a user selects a different value in the dropdown , on the autopostback I need to update the database with that value and then re-display the datagrid with the dropdown having the new value from the database.
Here's my code so far:
HTML:
<asp:datagrid id="grdResults" runat="server" Height="50px" Width="1200px"
Font-Names="Tahoma"Font-Size="XX-Small" ForeColor="Black" HorizontalAlign="Center"
CellSpacing="1" BorderStyle="Solid" AutoGenerateColumns="False"CellPadding="1"
PageSize="1" BorderColor="Silver">
<AlternatingItemStyle CssClass="GridAltItem">
</AlternatingItemStyle>
<HeaderStyle Font-Size="XX-small" Font-Bold="True"></HeaderStyle><Columns>
<asp:BoundColumn DataField="iID" visible="False" HeaderText="ID"></asp:BoundColumn>
<asp:BoundColumn DataField="iExceptionId" visible="False" HeaderText="ExceptionId"></asp:BoundColumn>
<asp:BoundColumn DataField="sType" HeaderText="Type"></asp:BoundColumn>
<asp:TemplateColumn HeaderText="Status">
<ItemTemplate>
<asp:DropDownList AutoPostback="true"
id="ddlStatus" DataSource="<%#BindState()%>"
TextField="sStatusName" DataValueField="iCmOtdExceptionStatusId" runat="server" Font-Name="Tahoma"
Font-Size ="xx-small" runat="server" />
</ItemTemplate>
</asp:TemplateColumn></Columns>
</asp:datagrid>
VB.NET:This populates the dropdown within the datagrid.
VB.NET:
Public Function BindState()
Dim myConnection As SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings("connString"))
Dim myCommand As SqlCommand = New SqlCommand("uspGetOTDExceptionStatus", myConnection)
myCommand.CommandType = CommandType.StoredProcedure
myConnection.Open()
Return myCommand.ExecuteReader(CommandBehavior.CloseConnection)
End Function
I can't figure out in which event I need to capture the new dropdown value and then call the stored proc that updates the value in the database.
Can someone help me please?
Thanks,
Ninel