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

Datagrid Template column

Scheduled Pinned Locked Moved ASP.NET
cssdatabasehelp
2 Posts 2 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.
  • C Offline
    C Offline
    chandru_inbox
    wrote on last edited by
    #1

    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)

    H 1 Reply Last reply
    0
    • C chandru_inbox

      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)

      H Offline
      H Offline
      hakanaktan
      wrote on last edited by
      #2

      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--

      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