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 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
i tried that already and cant get it to work...here is code i have so far...
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"
If Chk.Checked = False Then
MyCommand.CommandText = "update support.support set save = 0"
MyCommand = Nothing