Onchecked_change in gridview

  • Thread starter Thread starter roberta
  • Start date Start date
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
 
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
 
Back
Top