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. DATAGRID template column problem

DATAGRID template column problem

Scheduled Pinned Locked Moved ASP.NET
helpcsharpasp-netdatabaseannouncement
7 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.
  • F Offline
    F Offline
    Faisal Khatri
    wrote on last edited by
    #1

    Hi guys/ gals, I am working on ASP.NET 2.0. I have careted a datagrid in which ihave around 3 template columns each containing Checkboxes. I want to update the record based on that checkboxes. Like if there are three columns with name Status, Permissions, Active. so when i click the checkbox of the first row of status it should only change the status of that particular record in db with that status. I am confused how I can do it. plss reply me urgently... If anybody can help me with the code..that will be great.. Please help me.. KHATRI

    _ R 2 Replies Last reply
    0
    • F Faisal Khatri

      Hi guys/ gals, I am working on ASP.NET 2.0. I have careted a datagrid in which ihave around 3 template columns each containing Checkboxes. I want to update the record based on that checkboxes. Like if there are three columns with name Status, Permissions, Active. so when i click the checkbox of the first row of status it should only change the status of that particular record in db with that status. I am confused how I can do it. plss reply me urgently... If anybody can help me with the code..that will be great.. Please help me.. KHATRI

      _ Offline
      _ Offline
      _AK_
      wrote on last edited by
      #2

      When are you trying to updated the database? Suppose if the button is outside datagrid then you need to loopthrough all the items and find the checkbox and then depending on the selection status you can update the database.

      Best Regards, Apurva Kaushal

      F 1 Reply Last reply
      0
      • _ _AK_

        When are you trying to updated the database? Suppose if the button is outside datagrid then you need to loopthrough all the items and find the checkbox and then depending on the selection status you can update the database.

        Best Regards, Apurva Kaushal

        F Offline
        F Offline
        Faisal Khatri
        wrote on last edited by
        #3

        It is inside the datagrid. Its placed in the template column of the datagrid.. KHATRI

        _ 1 Reply Last reply
        0
        • F Faisal Khatri

          It is inside the datagrid. Its placed in the template column of the datagrid.. KHATRI

          _ Offline
          _ Offline
          _AK_
          wrote on last edited by
          #4

          In that case you can use OnItemCommand event of the datagrid. whenever you will click the button that event will get fired and there you can execute your storedprocedure to update the record.

          Best Regards, Apurva Kaushal

          F 1 Reply Last reply
          0
          • _ _AK_

            In that case you can use OnItemCommand event of the datagrid. whenever you will click the button that event will get fired and there you can execute your storedprocedure to update the record.

            Best Regards, Apurva Kaushal

            F Offline
            F Offline
            Faisal Khatri
            wrote on last edited by
            #5

            WEll i tried with ItemCommand Event of the Datagrid but its not working. Because I am not able to define a command with that Checkbox so to match with the Command inorder to process with the checkbox. Can i have ur personal msn id..? so ill explain you by sending you a picture.. if you can help me..? KHATRI

            _ 1 Reply Last reply
            0
            • F Faisal Khatri

              WEll i tried with ItemCommand Event of the Datagrid but its not working. Because I am not able to define a command with that Checkbox so to match with the Command inorder to process with the checkbox. Can i have ur personal msn id..? so ill explain you by sending you a picture.. if you can help me..? KHATRI

              _ Offline
              _ Offline
              _AK_
              wrote on last edited by
              #6

              What you want to do is whenever user checks the checkbox you want to fire the event and update the database, if this is your case then it won't be a good idea. Inspite of that you can put a button and on click event of that button you can loop through all the items and check which one has been checked and those will be updated to the database.

              Best Regards, Apurva Kaushal

              1 Reply Last reply
              0
              • F Faisal Khatri

                Hi guys/ gals, I am working on ASP.NET 2.0. I have careted a datagrid in which ihave around 3 template columns each containing Checkboxes. I want to update the record based on that checkboxes. Like if there are three columns with name Status, Permissions, Active. so when i click the checkbox of the first row of status it should only change the status of that particular record in db with that status. I am confused how I can do it. plss reply me urgently... If anybody can help me with the code..that will be great.. Please help me.. KHATRI

                R Offline
                R Offline
                RaghuSanta
                wrote on last edited by
                #7

                Hi Faisal, Here i have listed some steps according to your requirement. Hope this will be helpful. 1. Modify your template column in the datagrid as below in the design/source view. 2.In the Vb code file, Create a Procedure which be called when the checkbox state is changed. Private Sub OnStatusChangedEvent(ByVal sender As Object, ByVal e As System.EventArgs) Dim cboxStatus As CheckBox Dim dGrid As DataGridItem cboxStatus= CType(sender, CheckBox) 'This will inherit the datagrid template checkbox propeties which you have clicked dGrid = CType(cboxStatus.NamingContainer, DataGridItem) 'If you need to find the text value in any datagrid column for ex. ID then Dim id as integer=dGrid.Cells(0).Text 'Here id is the first column in the datagrid for your example If cboxStatus.Checked = True Then 'Do the sql insert/update here by passing the id. End If End Sub This will be useful only when you want to update a row by changing the Checbox state in the template. Otherwise if you need to update multiple row you have to loop through all rows and write a procedure in a button click event(When you use button click event set autopostback="false" in the checkbox). Regards, Raghu -- modified at 4:54 Friday 27th April, 2007

                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