ASP.NET 2.0 BasicsIf you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
i think by default checkboxes are disabled. I want to enable all checkbox items, so that user can check or uncheck. How can i do that and how can i retrieve these values?
Sorry. We have modified our code and no longer we are using checkboxes and hence i don't have working code for this. Please tell here your problem, so that we can figure it out.
i have a gridview with several columns and a templatefield containing a checkbox. when the user clicks the checkbox i want to update the database with a 1 (if checked) or a 0 (if unchecked). also, it must only update the row that was checked and not the entire thing
you can find that checkbox using gridview item. find method for each row and use .checked method whether its checked or not.. and update your database.
i tried that already and cant get it to work...here is code i have so far...
Code:
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
Dim MyConnection As OdbcConnection
MyConnection = New OdbcConnection() 'declare new connection object
MyConnection.ConnectionString = "" 'database connect string
MyConnection.Open() 'open connection to database
Dim MyCommand As New OdbcCommand() 'declare new command object
MyCommand.Connection = MyConnection
If e.Row.RowType = DataControlRowType.DataRow Then
Dim Chk As CheckBox = e.Row.Cells(5).FindControl("save")
If Chk.Checked = True Then
MyCommand.CommandText = "update support.support set save = 1"
End If
If Chk.Checked = False Then
MyCommand.CommandText = "update support.support set save = 0"
End If
MyCommand.ExecuteNonQuery()
MyConnection.Close()
MyCommand = Nothing
'MsgBox(Chk.Checked)
End If
End Sub