jeudi 29 janvier 2015

C# redirect to other page when gridview checkbox is ticked asp.net

i need you help guys,i have two pages and one with agridview with checkbox column, i want to redirect to the second page when the user tick the checkbox. here is my code :



<asp:BoundField DataField="BC_Description" HeaderText="Description">
<HeaderStyle BorderColor="Black" BorderStyle="Solid" BorderWidth="2px" HorizontalAlign="Center" />
<ItemStyle BorderColor="Black" BorderStyle="Solid" BorderWidth="2px" Width="290px"
HorizontalAlign="Left" />
</asp:BoundField>

<asp:BoundField DataField="Update_Comments" HeaderText="Comments">
<HeaderStyle BorderColor="Black" BorderStyle="Solid" BorderWidth="2px" HorizontalAlign="Center"
Width="100px" />
<ItemStyle BorderColor="Black" BorderStyle="Solid" BorderWidth="2px" Width="350px"
HorizontalAlign="Left" />
</asp:BoundField>

<asp:TemplateField HeaderText="Changed">
<HeaderStyle BorderColor="Black" BorderStyle="Solid" BorderWidth="2px" HorizontalAlign="Center" />
<ItemStyle BorderColor="Black" BorderStyle="Solid" BorderWidth="2px" Width="150px"
HorizontalAlign="Center" />
<ItemTemplate>
<asp:CheckBox ID="chkApprove" runat="server" />
</ItemTemplate>
</asp:TemplateField>


if (!IsPostBack)
{
ChangedBy = getInfo.GetUserDetails(compileUserDI);
foreach (GridViewRow row in GridView1.Rows)
{
CheckBox cb = (CheckBox)row.FindControl("chkApprove");

if (cb.Checked)
{
Response.Redirect("CompileVariance.aspx");
}
}




Aucun commentaire:

Enregistrer un commentaire