I have a datagrid bound to a sql proc. I have made the last column in the datagrid into text boxes so the items are editable. how do i return the values from these cells? Basically I want to be able to sum the entire column, as well as set the values in each item of the column to 0 upon a button_click. I'm very new to vb.net and if I'm not explaining this correctly please let me know.
the datagrid is built through this funtion:
Dim strConnString As String
Dim strSQLText As String
strConnString = ConfigurationManager.ConnectionStrings("SDWConnectionString").ToString
strSQLText = "SELECT TN_CN_S_Desc, Item, Pack, Location, Lot, Label_Nb from sdw.sdw_user.SAR_DTD_840_copy where Pick_Num = '" & Picklist & "'"
Dim SqlCOnnection As New SqlConnection(strConnString)
SqlCOnnection.Open()
Dim sqlCmd As New SqlCommand(strSQLText, SqlCOnnection)
Dim adapter As New SqlClient.SqlDataAdapter(strSQLText, SqlCOnnection)
Dim ds As New DataSet
adapter.Fill(ds, "sdw.sdw_user.SAR_DTD_840_copy")
Dim dataTable = ds.Tables("sdw.sdw_user.SAR_DTD_840_copy")
Me.DataGrid1.DataSource = dataTable
Me.DataGrid1.AutoGenerateColumns = False
Me.DataGrid1.DataBind()
the html for the column that I made editable and want to sum/set to zero looks like this:
<asp:TemplateColumn HeaderText="# Labels">
<EditItemTemplate>
<asp:TextBox ID="txtlbls" runat="server" Style="text-align: right" Text='<%# DataBinder.Eval(Container.DataItem,"Label_Nb") %>'
Width="65"></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:TextBox ID="txtlbls" runat="server" Style="text-align: right" Text='<%# DataBinder.Eval(Container.DataItem,"Label_Nb") %>'
Width="65"></asp:TextBox>
</ItemTemplate>
</asp:TemplateColumn>