473,395 Members | 1,556 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

checkbox on gridview

Hi, I am using a gridview with a templatefield containing a checkbox.
I want to update the database with a 1 or 0 depending on if a checkbox
is checked or unchecked (then use the 1 or 0 later on another page)..i
have been google around and found this....

If e.Row.RowType = DataControlRowType.DataRow Then

Dim Chk As CheckBox = e.Row.FindControl("CheckBox1")

just dont know what to do next...Any ideas?

Dec 12 '06 #1
9 5514

Well, how you do it depends on when you want to do the update. Basically you
need to indeed find the control in the row/column. When data is bound to the
grid, this event fires for each row bound to the control. The event args 'e'
is passed to the function and you can use this to check if the checkbox is
checked or not.

(Not tested but something like this)

'//e contains the Item which is the current row.
dim cb as checkbox

cb= Ctype(e.item(indexColumnNumber).controls(1),checkb ox)

if cb.selected = true then

'//do domething

end if

HTH
<mi********@yahoo.co.ukwrote in message
news:11*********************@80g2000cwy.googlegrou ps.com...
Hi, I am using a gridview with a templatefield containing a checkbox.
I want to update the database with a 1 or 0 depending on if a checkbox
is checked or unchecked (then use the 1 or 0 later on another page)..i
have been google around and found this....

If e.Row.RowType = DataControlRowType.DataRow Then

Dim Chk As CheckBox = e.Row.FindControl("CheckBox1")

just dont know what to do next...Any ideas?

Dec 12 '06 #2
Hi
I have expanded on what i had originally but still cant get it to
update DB...here is the new code i have....

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



Goofy wrote:
Well, how you do it depends on when you want to do the update. Basically you
need to indeed find the control in the row/column. When data is bound to the
grid, this event fires for each row bound to the control. The event args 'e'
is passed to the function and you can use this to check if the checkbox is
checked or not.

(Not tested but something like this)

'//e contains the Item which is the current row.
dim cb as checkbox

cb= Ctype(e.item(indexColumnNumber).controls(1),checkb ox)

if cb.selected = true then

'//do domething

end if

HTH
<mi********@yahoo.co.ukwrote in message
news:11*********************@80g2000cwy.googlegrou ps.com...
Hi, I am using a gridview with a templatefield containing a checkbox.
I want to update the database with a 1 or 0 depending on if a checkbox
is checked or unchecked (then use the 1 or 0 later on another page)..i
have been google around and found this....

If e.Row.RowType = DataControlRowType.DataRow Then

Dim Chk As CheckBox = e.Row.FindControl("CheckBox1")

just dont know what to do next...Any ideas?
Dec 12 '06 #3
breakpoint the line as shown below and see if you get an exception, if you
do look at the exception message and see what its telling you and go from
there.

Try

MyCommand.ExecuteNonQuery() '// breakpoint it here
Catch ex as Exception

End Try


"mike7510uk" <mi********@yahoo.co.ukwrote in message
news:11**********************@80g2000cwy.googlegro ups.com...
Hi
I have expanded on what i had originally but still cant get it to
update DB...here is the new code i have....

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



Goofy wrote:
>Well, how you do it depends on when you want to do the update. Basically
you
need to indeed find the control in the row/column. When data is bound to
the
grid, this event fires for each row bound to the control. The event args
'e'
is passed to the function and you can use this to check if the checkbox
is
checked or not.

(Not tested but something like this)

'//e contains the Item which is the current row.
dim cb as checkbox

cb= Ctype(e.item(indexColumnNumber).controls(1),checkb ox)

if cb.selected = true then

'//do domething

end if

HTH
<mi********@yahoo.co.ukwrote in message
news:11*********************@80g2000cwy.googlegro ups.com...
Hi, I am using a gridview with a templatefield containing a checkbox.
I want to update the database with a 1 or 0 depending on if a checkbox
is checked or unchecked (then use the 1 or 0 later on another page)..i
have been google around and found this....

If e.Row.RowType = DataControlRowType.DataRow Then

Dim Chk As CheckBox = e.Row.FindControl("CheckBox1")

just dont know what to do next...Any ideas?

Dec 12 '06 #4
Tried that and nothing happened, it loaded page up ok and let me click
the checkboxes but no DB update
Goofy wrote:
breakpoint the line as shown below and see if you get an exception, if you
do look at the exception message and see what its telling you and go from
there.

Try

MyCommand.ExecuteNonQuery() '// breakpoint it here
Catch ex as Exception

End Try


"mike7510uk" <mi********@yahoo.co.ukwrote in message
news:11**********************@80g2000cwy.googlegro ups.com...
Hi
I have expanded on what i had originally but still cant get it to
update DB...here is the new code i have....

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



Goofy wrote:
Well, how you do it depends on when you want to do the update. Basically
you
need to indeed find the control in the row/column. When data is bound to
the
grid, this event fires for each row bound to the control. The event args
'e'
is passed to the function and you can use this to check if the checkbox
is
checked or not.

(Not tested but something like this)

'//e contains the Item which is the current row.
dim cb as checkbox

cb= Ctype(e.item(indexColumnNumber).controls(1),checkb ox)

if cb.selected = true then

'//do domething

end if

HTH
<mi********@yahoo.co.ukwrote in message
news:11*********************@80g2000cwy.googlegrou ps.com...
Hi, I am using a gridview with a templatefield containing a checkbox.
I want to update the database with a 1 or 0 depending on if a checkbox
is checked or unchecked (then use the 1 or 0 later on another page)..i
have been google around and found this....

If e.Row.RowType = DataControlRowType.DataRow Then

Dim Chk As CheckBox = e.Row.FindControl("CheckBox1")

just dont know what to do next...Any ideas?
Dec 12 '06 #5
am i even running the code in the correct sub?
mike7510uk wrote:
Tried that and nothing happened, it loaded page up ok and let me click
the checkboxes but no DB update
Goofy wrote:
breakpoint the line as shown below and see if you get an exception, if you
do look at the exception message and see what its telling you and go from
there.

Try

MyCommand.ExecuteNonQuery() '// breakpoint it here
Catch ex as Exception

End Try


"mike7510uk" <mi********@yahoo.co.ukwrote in message
news:11**********************@80g2000cwy.googlegro ups.com...
Hi
I have expanded on what i had originally but still cant get it to
update DB...here is the new code i have....
>
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
>
>
>
>
>
>
>
>
>
>
>
Goofy wrote:
>Well, how you do it depends on when you want to do the update. Basically
>you
>need to indeed find the control in the row/column. When data is bound to
>the
>grid, this event fires for each row bound to the control. The event args
>'e'
>is passed to the function and you can use this to check if the checkbox
>is
>checked or not.
>>
>(Not tested but something like this)
>>
>'//e contains the Item which is the current row.
>dim cb as checkbox
>>
>cb= Ctype(e.item(indexColumnNumber).controls(1),checkb ox)
>>
>if cb.selected = true then
>>
>'//do domething
>>
>end if
>>
>HTH
>>
>>
><mi********@yahoo.co.ukwrote in message
>news:11*********************@80g2000cwy.googlegro ups.com...
Hi, I am using a gridview with a templatefield containing a checkbox.
I want to update the database with a 1 or 0 depending on if a checkbox
is checked or unchecked (then use the 1 or 0 later on another page)..i
have been google around and found this....
>
If e.Row.RowType = DataControlRowType.DataRow Then
>
Dim Chk As CheckBox = e.Row.FindControl("CheckBox1")
>
just dont know what to do next...Any ideas?
>
>
Dec 12 '06 #6
with the code you posted earlier ('//e contains the Item which is the
current row.
dim cb as checkbox
cb= Ctype(e.item(indexColumnNumber).controls(1),checkb ox)
if cb.selected = true then
'//do domething
end if )

i get the error saying "item is not a member of system.web etc etc

mike7510uk wrote:
am i even running the code in the correct sub?
mike7510uk wrote:
Tried that and nothing happened, it loaded page up ok and let me click
the checkboxes but no DB update
Goofy wrote:
breakpoint the line as shown below and see if you get an exception, if you
do look at the exception message and see what its telling you and go from
there.
>
Try
>
MyCommand.ExecuteNonQuery() '// breakpoint it here
>
>
Catch ex as Exception
>
>
>
End Try
>
>
>
>
"mike7510uk" <mi********@yahoo.co.ukwrote in message
news:11**********************@80g2000cwy.googlegro ups.com...
Hi
I have expanded on what i had originally but still cant get it to
update DB...here is the new code i have....

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











Goofy wrote:
Well, how you do it depends on when you want to do the update. Basically
you
need to indeed find the control in the row/column. When data is bound to
the
grid, this event fires for each row bound to the control. The event args
'e'
is passed to the function and you can use this to check if the checkbox
is
checked or not.
>
(Not tested but something like this)
>
'//e contains the Item which is the current row.
dim cb as checkbox
>
cb= Ctype(e.item(indexColumnNumber).controls(1),checkb ox)
>
if cb.selected = true then
>
'//do domething
>
end if
>
HTH
>
>
<mi********@yahoo.co.ukwrote in message
news:11*********************@80g2000cwy.googlegrou ps.com...
Hi, I am using a gridview with a templatefield containing a checkbox.
I want to update the database with a 1 or 0 depending on if a checkbox
is checked or unchecked (then use the 1 or 0 later on another page)..i
have been google around and found this....

If e.Row.RowType = DataControlRowType.DataRow Then

Dim Chk As CheckBox = e.Row.FindControl("CheckBox1")

just dont know what to do next...Any ideas?
Dec 12 '06 #7
mike7510uk wrote:
Tried that and nothing happened, it loaded page up ok and let me click
the checkboxes but no DB update
Goofy wrote:
>breakpoint the line as shown below and see if you get an exception, if you
do look at the exception message and see what its telling you and go from
there.

Try

MyCommand.ExecuteNonQuery() '// breakpoint it here
Catch ex as Exception

End Try


"mike7510uk" <mi********@yahoo.co.ukwrote in message
news:11**********************@80g2000cwy.googlegr oups.com...
>>Hi
I have expanded on what i had originally but still cant get it to
update DB...here is the new code i have....

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



Goofy wrote:
Well, how you do it depends on when you want to do the update. Basically
you
need to indeed find the control in the row/column. When data is bound to
the
grid, this event fires for each row bound to the control. The event args
'e'
is passed to the function and you can use this to check if the checkbox
is
checked or not.

(Not tested but something like this)

'//e contains the Item which is the current row.
dim cb as checkbox

cb= Ctype(e.item(indexColumnNumber).controls(1),checkb ox)

if cb.selected = true then

'//do domething

end if

HTH
<mi********@yahoo.co.ukwrote in message
news:11*********************@80g2000cwy.googleg roups.com...
Hi, I am using a gridview with a templatefield containing a checkbox.
I want to update the database with a 1 or 0 depending on if a checkbox
is checked or unchecked (then use the 1 or 0 later on another page)..i
have been google around and found this....
>
If e.Row.RowType = DataControlRowType.DataRow Then
>
Dim Chk As CheckBox = e.Row.FindControl("CheckBox1")
>
just dont know what to do next...Any ideas?
>
How are you specifying where to do the update within your support table?
MyCommand.CommandText = "update support.support set save = 0"

I'm not an expert, but I couldn't find anything in your code (update sql
statement) that would tell the database where in the table to do the update.
Dec 12 '06 #8
Ok, im confused now..

Basically, i want a gridview with a templatefield (or checkboxfield)
with a checkbox on it that when the user clicks the checkbox it sends a
1 or 0 value back to DB (1 for checked and 0 for unchecked)
Jim in Arizona wrote:
mike7510uk wrote:
Tried that and nothing happened, it loaded page up ok and let me click
the checkboxes but no DB update
Goofy wrote:
breakpoint the line as shown below and see if you get an exception, if you
do look at the exception message and see what its telling you and go from
there.

Try

MyCommand.ExecuteNonQuery() '// breakpoint it here
Catch ex as Exception

End Try


"mike7510uk" <mi********@yahoo.co.ukwrote in message
news:11**********************@80g2000cwy.googlegro ups.com...
Hi
I have expanded on what i had originally but still cant get it to
update DB...here is the new code i have....

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



Goofy wrote:
Well, how you do it depends on when you want to do the update. Basically
you
need to indeed find the control in the row/column. When data is bound to
the
grid, this event fires for each row bound to the control. The event args
'e'
is passed to the function and you can use this to check if the checkbox
is
checked or not.

(Not tested but something like this)

'//e contains the Item which is the current row.
dim cb as checkbox

cb= Ctype(e.item(indexColumnNumber).controls(1),checkb ox)

if cb.selected = true then

'//do domething

end if

HTH
<mi********@yahoo.co.ukwrote in message
news:11*********************@80g2000cwy.googlegr oups.com...
Hi, I am using a gridview with a templatefield containing a checkbox.
I want to update the database with a 1 or 0 depending on if a checkbox
is checked or unchecked (then use the 1 or 0 later on another page)..i
have been google around and found this....

If e.Row.RowType = DataControlRowType.DataRow Then

Dim Chk As CheckBox = e.Row.FindControl("CheckBox1")

just dont know what to do next...Any ideas?

How are you specifying where to do the update within your support table?
MyCommand.CommandText = "update support.support set save = 0"

I'm not an expert, but I couldn't find anything in your code (update sql
statement) that would tell the database where in the table to do the update.
Dec 13 '06 #9
I have now managed to do this (at last)
here is the code...

Protected Sub save_CheckedChanged(ByVal sender As Object, ByVal e As
System.EventArgs)

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

Dim cID As Integer = 0
' Dim str As StringBuilder = New StringBuilder
Dim i As Integer = 0
Dim state As Integer
For i = 0 To GridView1.Rows.Count - 1
'Dim row As GridViewRow = GridView1.Rows(i)
Dim isChecked As Boolean =
CType(GridView1.Rows(i).FindControl("save"), CheckBox).Checked
If isChecked Then
state = 1
Else
state = 0
End If

MyCommand.CommandText = "update support.support set save =?
where id=?"
MyCommand.Parameters.Clear()
MyCommand.Parameters.Add(New OdbcParameter("@state",
state))
MyCommand.Parameters.Add(New OdbcParameter("@id",
GridView1.Rows(i).Cells(0).Text))
MyCommand.ExecuteNonQuery()
Next

MyConnection.Close()
MyCommand = Nothing
End Sub

All i need to do now is if a user checks a particular checkbox, it
remains checked the next time they visit the page..

mike7510uk wrote:
Ok, im confused now..

Basically, i want a gridview with a templatefield (or checkboxfield)
with a checkbox on it that when the user clicks the checkbox it sends a
1 or 0 value back to DB (1 for checked and 0 for unchecked)
Jim in Arizona wrote:
mike7510uk wrote:
Tried that and nothing happened, it loaded page up ok and let me click
the checkboxes but no DB update
Goofy wrote:
>breakpoint the line as shown below and see if you get an exception, if you
>do look at the exception message and see what its telling you and go from
>there.
>>
>Try
>>
> MyCommand.ExecuteNonQuery() '// breakpoint it here
>>
>>
>Catch ex as Exception
>>
>>
>>
>End Try
>>
>>
>>
>>
>"mike7510uk" <mi********@yahoo.co.ukwrote in message
>news:11**********************@80g2000cwy.googlegr oups.com...
>>Hi
>>I have expanded on what i had originally but still cant get it to
>>update DB...here is the new code i have....
>>>
>>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
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>Goofy wrote:
>>>Well, how you do it depends on when you want to do the update. Basically
>>>you
>>>need to indeed find the control in the row/column. When data is bound to
>>>the
>>>grid, this event fires for each row bound to the control. The event args
>>>'e'
>>>is passed to the function and you can use this to check if the checkbox
>>>is
>>>checked or not.
>>>>
>>>(Not tested but something like this)
>>>>
>>>'//e contains the Item which is the current row.
>>>dim cb as checkbox
>>>>
>>>cb= Ctype(e.item(indexColumnNumber).controls(1),checkb ox)
>>>>
>>>if cb.selected = true then
>>>>
>>>'//do domething
>>>>
>>>end if
>>>>
>>>HTH
>>>>
>>>>
>>><mi********@yahoo.co.ukwrote in message
>>>news:11*********************@80g2000cwy.googleg roups.com...
>>>>Hi, I am using a gridview with a templatefield containing a checkbox.
>>>>I want to update the database with a 1 or 0 depending on if a checkbox
>>>>is checked or unchecked (then use the 1 or 0 later on another page)..i
>>>>have been google around and found this....
>>>>>
>>>>If e.Row.RowType = DataControlRowType.DataRow Then
>>>>>
>>>>Dim Chk As CheckBox = e.Row.FindControl("CheckBox1")
>>>>>
>>>>just dont know what to do next...Any ideas?
>>>>>
>
How are you specifying where to do the update within your support table?
MyCommand.CommandText = "update support.support set save = 0"

I'm not an expert, but I couldn't find anything in your code (update sql
statement) that would tell the database where in the table to do the update.
Dec 13 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Bill44077 | last post by:
I am dynamically adding a checkbox in a gridview and I find there are several things that I cannot figure out how to address. 1. The width of the checkbox column is very wide. I've tried adding...
0
by: Jayender | last post by:
Hi , I have placed checkbox in my gridview .. now when i check the chekbox and click anybutton the checkbox becomes unchecked. but when i normally add checkbox in the page it doesnt happen but...
1
by: mercercreek | last post by:
This one should be easy. Hope someone has a clue. Simple Scenario: Gridview with mulitple rows, each row with a checkbox. The user checks boxes of her choice. Clicks a button on the form (not in...
2
by: JonBosker | last post by:
I am having a strange problem - my GridView is displaying bits (from SQL Server) as checkboxes (which is fine) but it shows each alternating one centrally aligned. Heading1 Heading2 Text ...
1
by: Ben | last post by:
Hi, I'm designing a c# page and trying to add a checkbox column to a GridView, I've added a Template Row (as described at: http://aspnet.4guysfromrolla.com/articles/052406-1.aspx) and in the...
1
by: aurovinda | last post by:
Hi I send the detail code below.I have the problem when i click the checkbox there is no effect on the gridview's row.Again after a few seconds the checkbox is automatically unchecked.There is...
1
by: Danielle | last post by:
Greetings all and thanks in advance for any help you can provide. I am trying ultimately to get values from a gridview row when a checkbox on the row is checked. the problem I'm having is that...
0
by: dotnetrookie | last post by:
Hi This is my 1st post.I have two checkbox columns in gridview binded through item template. The checkboxes are Category and Subcategory. I have actually removed the duplicate values in the...
1
by: janetb | last post by:
I have a gridview with an update capabilities - a textbox column (roomName), a dropdownlist(orgID), a dropdownlist(roomTypeID),a checkbox column (dialOut), a checkbox column (dialIn). When I try to...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.