DataGrid templet column question?

  • Thread starter Thread starter jiangyh
  • Start date Start date
J

jiangyh

hi there:

I have a datagrid in my web form that contain a templet column.And in
this templet column have a checkbox web control.I will get the checkbox
state in my
serverside.

My question is which server-side event I will add to my codebehind when
I change the
checkbox state of the DataGrid templet column.

Thanks in advice.
jiangyh
 
Hi jiangyh:

Set the AutoPostBack property of the CheckBox control to true, and you
can catch the CheckedChanged event just after the user clicks on the
control.
 
hi Scott Allen:

thanks you help,but which event I will add can catch user click at
server-side.

jiangyh
 
The CheckedChanged event.

<asp:CheckBox id="CheckBox1" runat="server"
AutoPostBack="True"
OnCheckedChanged="CheckBox1_CheckedChanged"/>

Add this to the template and the check box will appear in each row.
The CheckBox1_CheckedChanged event will fire on the server side.
 
yes Scott Allen thanks


Scott Allen said:
The CheckedChanged event.

<asp:CheckBox id="CheckBox1" runat="server"
AutoPostBack="True"
OnCheckedChanged="CheckBox1_CheckedChanged"/>

Add this to the template and the check box will appear in each row.
The CheckBox1_CheckedChanged event will fire on the server side.
 
hi Scott Allen:

I can fire on the server side but I can't get the checkbox state at the
server side.

For example if my checkbox's state is true.at client side I click it and
change it state to false.But I always get the checkbox's state is true at
serverside.

what's wrong with me? thanks a lot
jiangyh.


<ItemTemplate>
<asp:CheckBox id="chkBox" runat="server"
OnCheckedChanged="CheckBoxChange" AutoPostBack="True"
ForeColor="White" Font-Names="Verdana" Font-Size="XX-Small"
Checked=True></asp:CheckBox>
</ItemTemplate>

CheckBox check =
(CheckBox)dgdName.Items.Cells[1].FindControl("chkBox");
Response.write(check.Checked);

the result is true.
 
Does Items reference the correct row, or are you looping through
all the Items?

hi Scott Allen:

I can fire on the server side but I can't get the checkbox state at the
server side.

For example if my checkbox's state is true.at client side I click it and
change it state to false.But I always get the checkbox's state is true at
serverside.

what's wrong with me? thanks a lot
jiangyh.


<ItemTemplate>
<asp:CheckBox id="chkBox" runat="server"
OnCheckedChanged="CheckBoxChange" AutoPostBack="True"
ForeColor="White" Font-Names="Verdana" Font-Size="XX-Small"
Checked=True></asp:CheckBox>
</ItemTemplate>

CheckBox check =
(CheckBox)dgdName.Items.Cells[1].FindControl("chkBox");
Response.write(check.Checked);

the result is true.
 
Back
Top