473,326 Members | 2,192 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,326 software developers and data experts.

OnCheckedChanged event does not seem to execute (checkbox ingridview)

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 after
ticking the checkbox, the whole page refreshes (expectedly), the
checkbox is unmarked and the response.write message displayed below
never displays. It follows that if I uncomment the lines that try to
capture the value in cell(3) and display that variable nothing is
displayed.
The gridview is standard issue so I've included only the
TemplateField
for the checkbox:
<asp:TemplateField >
<ItemTemplate>
<asp:CheckBox ID="chkContactSelect"
runat="server"
AutoPostBack="true"
OnCheckedChanged="chkContactSelect_CheckedChanged" />
</ItemTemplate>
</asp:TemplateField>
Here's the code for the sub:
Protected Sub chkContactSelect_CheckedChanged(ByVal sender As
Object, ByVal e As System.EventArgs)
Dim selectedCheckbox As CheckBox
selectedCheckbox = CType(sender, CheckBox)
Dim selectedRow As GridViewRow
selectedRow = CType(selectedCheckbox.NamingContainer,
GridViewRow)
If selectedCheckbox.Checked = True Then
'Text = selectedRow.Cells(3).Text
'Response.Write(Text)
Response.Write("test")
End If
End Sub
Thanks again for any help-
Danielle
Jun 27 '08 #1
1 4134
On Jun 8, 1:31*am, Danielle <wxb...@aol.comwrote:
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 after
ticking the checkbox, the whole page refreshes (expectedly), the
checkbox is unmarked and the response.write message displayed below
never displays. *It follows that if I uncomment the lines that try to
capture the value in cell(3) and display that variable nothing is
displayed.

The gridview is standard issue so I've included only the
TemplateField
for the checkbox:

<asp:TemplateField >
* * * * * * * * * * <ItemTemplate>
* * * * * * * * * * * * <asp:CheckBox ID="chkContactSelect"
runat="server"
* * * * * * * * * * * * AutoPostBack="true"

OnCheckedChanged="chkContactSelect_CheckedChanged" />
* * * * * * * * * * </ItemTemplate>
* * * * * * * * </asp:TemplateField>

Here's the code for the sub:

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

* * * * Dim selectedCheckbox As CheckBox
* * * * selectedCheckbox = CType(sender, CheckBox)

* * * * Dim selectedRow As GridViewRow
* * * * selectedRow = CType(selectedCheckbox.NamingContainer,
GridViewRow)

* * * * If selectedCheckbox.Checked = True Then
* * * * * * 'Text = selectedRow.Cells(3).Text
* * * * * * 'Response.Write(Text)
* * * * * * Response.Write("test")
* * * * End If

* * End Sub

Thanks again for any help-
Danielle
Hi Daniell

Rather than subscribing checkbox's on check event...

assign the checkbox a commandname and subscribe the item command event
of gridview...

when user click on checkbox it will fire the grids item command ... by
traping the commandname do your work

Best of luck

Munna
www.munna.shatkotha.com
www.munna.shatkotha.com/blog
www.shatkotha.com
Jun 27 '08 #2

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

Similar topics

2
by: mike | last post by:
Am I correct in assuming that when the starting value of a select list is re-selected, the onChange command does not execute? I need to have it execute when the original value is selected if...
9
by: J.Marsch | last post by:
I must be missing something here: The Init event for controls does not seem to fire. What I did: Drop a textbox on a blank webform, hook the textbox's Init event. Code: this.Textbox1.Value =...
0
by: Markus Poehler | last post by:
Hi there! I have created NT Service that runs on a Server. It should NET SEND to a specifiv Client in a special case of environment. It does NOT net send. The Messenger Service is running....
2
by: bizt | last post by:
Hi, Is it possible to obtain the width/ height of an image when that image is dyanically created using a PHP script and passing GET attributes. For example: <img...
1
by: Dennis | last post by:
I've noticed some old posts regarding this issue; but nothing recently and no resolutions in the old postings. Its almost hard for me to believe that this wouldn't be fixed by now. I am using...
1
by: mark4asp | last post by:
Here is the control: <asp:CheckBox ID="chkLite" runat="server" Checked="False" AutoPostBack="True" OnCheckedChanged="chkLite_CheckedChanged" /> Here is the code-behind: ...
1
by: Lila Godel | last post by:
My VB.NET 2008 application is setup with a Sub Main and no forms. At run time a NotifyIcon is created with one context menu choice (Close which terminates app). I have no trouble running the...
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...
1
by: jagdeep gupta | last post by:
In form I have added two radio button and on one radio button oncheckedchanged event has been registered but this event does happen only when i select the button and not when i select the other(The...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.