Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. add a check box to a data grid column

add a check box to a data grid column

Scheduled Pinned Locked Moved ASP.NET
css
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    miftha
    wrote on last edited by
    #1

    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

    R R 2 Replies Last reply
    0
    • M miftha

      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

      R Offline
      R Offline
      Rajiya
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • M miftha

        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

        R Offline
        R Offline
        Ritesh1234
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups