Checkbox update in GridView

vozz

New Member
When people search on my website using a \[code\]GridView\[/code\] I would like to have a \[code\]checkbox\[/code\] column that they click on which will change the value in a column called \[code\]STATUS\[/code\] to \[code\]U\[/code\]. I'm having a heck of a time finding code that works so I was hoping you guys could help. I'm a COMPLETE NOOB so please be descriptive if you know the answer.Code for \[code\]Checkbox\[/code\] button - Currently when I search it comes back saying that it cannot convert string to \[code\]boolean\[/code\].\[code\] <asp:TemplateField HeaderText="Successful Contact?"> <EditItemTemplate> <asp:CheckBox ID="CheckBox1" runat="server" checked='<%#Bind("status")%>' AutoPostBack="true" /> </EditItemTemplate> <ItemTemplate> <asp:CheckBox ID="CheckBox1" runat="server" checked='<%#Bind("status")%>' Enabled="False" /></ItemTemplate> </asp:TemplateField> \[/code\]This is the vb code \[code\] Protected Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As GridViewUpdateEventArgs) For Each GridViewRow In GridView1.Rows Dim row As GridViewRow = GridView1.Rows(e.RowIndex) Dim value As Boolean value = http://stackoverflow.com/questions/14425657/DirectCast(GridView1.Rows(e.RowIndex).Cells(0).FindControl("CheckBox1"), CheckBox).Checked Dim connectionString As String = ConfigurationManager.ConnectionStrings("Data Source=server;Initial Catalog=i3FCC01;Integrated Security=True;").ConnectionString Dim com_sql As New SqlClient.SqlCommand Dim insertSql As String insertSql = "Update CallQueueFCC Set Status='U' where Id = @id" Using myConnection As New SqlConnection(connectionString) myConnection.Open() Dim myCommand As New SqlCommand(insertSql, myConnection) myCommand.Parameters.AddWithValue("@status", value) myCommand.ExecuteNonQuery() myConnection.Close() End Using Next GridView1.EditIndex = -1 DataBind()End Sub\[/code\]
 
Back
Top