473,326 Members | 2,113 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 2882
Danielle wrote:
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.
I forget the exact syntax, but I suspect that your page load is running on post
backs. It is common to include a condition, something like
If Not request.IsPostBack Then
' do page load...

so that the page is not reloaded on the server in response to a post back. That
way the state of the grid is not changed, and you can retrieve the result.

Sorry I don't have the exact details, but with the above, and perhaps a
ViewState = True setting somewhere, you should be able to get the result.

Jun 27 '08 #2

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

Similar topics

0
by: Maziar Aflatoun | last post by:
Hi everyone, I am reading and displaying data rows from my database where the first column contains the Status checkbox. I like to enable my users to change the status of individual rows by...
2
by: Homa | last post by:
Hi, I have a Datagrid that uses as a shopping cart and have a checkbox template column in it. I can't add both OnCheckedChanged Event and onclick client script for it. I want to do two...
0
by: Oz | last post by:
Hi Using VS.NET 2003, Windows XP SP1, We have a page which has been developed using ASP.NET. On it, is a button which when clicked is supposed to add some data to a table. When the button is...
2
by: Maziar Aflatoun | last post by:
Hi everyone, I am reading and displaying data rows from my database where the first column contains the Status checkbox. I like to enable my users to change the status of individual rows by...
3
by: theycallmetish | last post by:
hey. i'll get right into it. i've got a codebehind page and m presentation page. i've got this code for my checkbox, which in theor is supposed to (when checked) take the first and last name of th...
4
by: Assimalyst | last post by:
Hi, I have a AutoPostBack checkbox and need to set a value bSubmitted = true when the checkbox is checked in order to prevent a warning message appearing notifying the user they are navigating...
1
by: writebrent | last post by:
Odd thing: if I check the checkbox, the code works fine. If I uncheck the checkbox, I get nothing, not even the "Executed" that's supposed to show up (as you'll see in the code). Thanks for any...
2
by: Mufasa | last post by:
How can I make an asp:radiobutton where when the user selects it it runs javascript code? I've tried doing the following but it doesn't seem to work: ...
1
by: QuickBooksDev | last post by:
VB.NET 2005 DataGridView Checkbox - Check Event need to know check status I would like to use the DataGridView Checkbox like a normal checkbox. When someone clicks on it I would expect that I...
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
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: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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.