Datagrid Template column
-
Hello, I bind datas in the datagrid from the database in that grid 3 columns. 1. Username, 2. Password and final Template column(in that column used checkbox control) and one button in the web form the button caption 'DELETE' when i press the delete button i want to delete Username and password Wheather it is checked by the Template column(checkbox column). Pls help me to validate the template column (CheckBox column i want to check it select or not)
-
Hello, I bind datas in the datagrid from the database in that grid 3 columns. 1. Username, 2. Password and final Template column(in that column used checkbox control) and one button in the web form the button caption 'DELETE' when i press the delete button i want to delete Username and password Wheather it is checked by the Template column(checkbox column). Pls help me to validate the template column (CheckBox column i want to check it select or not)
I had written a code that updates the rows that has checkbox checked. So i changed it a little for u.The idea is ; When user clicks the "delete" button start a search on datagrid rows to catch checkBox then delete that row if it is checked. Hope it helps.. Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click Dim connection As New SqlConnection(ConfigurationSettings.AppSettings("SqlConnect")) Dim comStr As String connection.Open() 'Search all rows for checkbox in datagrid For rowCounter As Integer = 0 To myDgrid.Items.Count - 1 Dim keyID As String = myDgrid.DataKeys(rowCounter) 'name of checkBox is Checks in Template Column If CType(myDgrid.Items(rowCounter).FindControl("Checks"), CheckBox).Checked Then comStr = "delete FROM myTable WHERE keyID=@keyID " Dim command As New SqlCommand(comStr, connection) command.Parameters.Add("@keyID", keyID) command.ExecuteNonQuery() command.Dispose() Next End If 'End Of Checked IF. Next connection.Close() --junior coder--