Onchecked_change in gridview

R

roberta

I've a grid view with a checkbox

<asp:TemplateField HeaderText="Attiva" HeaderStyle-HorizontalAlign="Center">
<ItemTemplate>
<div align="center">
<asp:CheckBox ID="chkAttiva" runat="server"
Checked='<%# Eval("Attivta") %>'
oncheckedchanged="chkAttiva_CheckedChanged"
AutoPostBack="true"></asp:CheckBox>
</div>
</ItemTemplate>
<ItemStyle Width="60px"></ItemStyle>
</asp:TemplateField>



I've the method for manage the check changed event

protected void chkAttiva_CheckedChanged(object sender, EventArgs e)
{

}


In this event I would like to know the value of the checkbox for the
selected row (checked true or false) ... is it possible?

Thanks
 
M

Mr. Arnold

roberta said:
I've a grid view with a checkbox

<asp:TemplateField HeaderText="Attiva"
HeaderStyle-HorizontalAlign="Center">
<ItemTemplate>
<div align="center">
<asp:CheckBox ID="chkAttiva" runat="server"
Checked='<%# Eval("Attivta") %>'
oncheckedchanged="chkAttiva_CheckedChanged"
AutoPostBack="true"></asp:CheckBox>
</div>
</ItemTemplate>
<ItemStyle Width="60px"></ItemStyle>
</asp:TemplateField>



I've the method for manage the check changed event

protected void chkAttiva_CheckedChanged(object sender, EventArgs e)
{

}


In this event I would like to know the value of the checkbox for the
selected row (checked true or false) ... is it possible?

Thanks

I think you're going to have to use the RowDataBound event for the
gridview control, and within the event you do a FindControl() 'chkAttiva'.

If object not null on FindControl, then you cast the object to object of
checkbox. You then check the object cast to a checkbox.value to be
true or false (checked or not checked).

The link kind of shows you how to use the RowDataBound and a FindControl
on the row, which the event is going to be fired for each row showing on
the page but only one row in bound. You can look-up the event yourself
for more information -- use Google.

http://msdn.microsoft.com/en-us/library/aa479353.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,705
Latest member
Stefkari24

Latest Threads

Top