add a check box to a data grid column
-
I want to know how I can add a check box to a data grid column so i can select multiple rows as selected. Also if it is not possible can I use the select button and then identify several records as selected to be used for processing thanks AMIF
Hi, In ur .aspx file add the following column as the first column to ur Datagrid: Then u can have a select Button which will have OnClick event and Display the deails based on the Checkboxes selected in the datagrid. e.g. Private Sub submit1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles submit1.Click Dim dgi As DataGridItem For Each dgi In BackorderDG.Items Dim bool As Boolean = CType(dgi.FindControl("SelectCheckBox"), CheckBox).Checked If bool = True Then --- Ur code to perform some actions .............. ............. End If Next End Sub Or else u can have a code to create a check box in ur .aspx.vb file like follows: Protected Function addCheckBox(ByVal chkValue As String) As String Dim chkBox As String = "" Return chkBox End Function Regards, Riz -- modified at 0:52 Tuesday 7th March, 2006
-
I want to know how I can add a check box to a data grid column so i can select multiple rows as selected. Also if it is not possible can I use the select button and then identify several records as selected to be used for processing thanks AMIF
Hi, you can add Template column and than add the checkbox in it lkie..... and in codebehind you can filter out the selected Row by navigating each DatagridRow and check if the checkbox is Checked or Not......e.g
Private Sub butFindRows_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butFindRows.Click Try Dim intTotalRow As Integer = 0 Dim intCounter As Integer For intCounter = 0 To dgGrid.Items.Count - 1 Dim cbCheckBox As CheckBox cbCheckBox = CType(dgGrid.Items(intCounter).FindControl("cbSelect"), CheckBox) If Not cbCheckBox Is Nothing Then If cbCheckBox.Checked Then intTotalRow += 1 End If End If Next Response.Write("Total no of selected rows :" & intTotalRow.ToString) Catch exc As Exception End Try End Sub
I hope this will help u......... Regards, Ritesh