.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

checkbox inside datagrid control

Posted By: Naresh     Posted Date: December 11, 2009    Points:2   Category :ASP.Net
hi,
i need to do some operation when checkbox is checked inside a datagrid.

Responses
Author: Amit Mehra             
Posted Date: December 12, 2009     Points: 5   

Hi Malathy,

Did you mean GridView? If yes than you can have template column inside Gridview control like this

<asp:TemplateField HeaderText="Approved" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center">
<HeaderTemplate>
<asp:CheckBox ID="chkCheckAll" runat="server" AutoPostBack="true" EnableViewState="true"
OnCheckedChanged="chkCheckAll_CheckedChanged" />
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="ChkStatus" AutoPostBack="true" runat="server" Checked='<%# Bind("IsStatus") %>'
OnCheckedChanged="ChkStatus_CheckedChanged" />
</ItemTemplate>
</asp:TemplateField>


Thanks
Amit

Thanks,
Amit
Please "Mark As Answer " if this post help you.
Author: Naresh             
Posted Date: December 12, 2009     Points: 5   

hi Amit,
Thanks for ur reply. but not in gridview. In asp.net web application , datagrid. I added the checkbox control inside the datagrid. But when i check the check box , i want to transfer the row values to another page.

Thanks
Naresh
Author: Amit Mehra             
Posted Date: December 12, 2009     Points: 5   

Hi malathy,

I guess you are using Asp.net 1.1. If yes you can modify the below code to implement in gridView it will be almost same.

To get the selected value from checkbox you can use this code

 CheckBox Chk = new CheckBox();
GridViewRow D = default(GridViewRow);
string EmployeeID = "";

foreach (var D in GVTD.Rows) {
Chk = D.FindControl("ChkSelect");
if (Chk.Checked == true) {
EmployeeID = D.Cell(1).Text.Trim();
}
}



Now you can use session object to store the selected row or cells value like this


Session.Add("Value1", DataGrid1.Items[1].Cells[2].Text)

Session.Add("Value2", DataGrid1.Items[1].Cells[2].Text)

Response.Redirect("MyNestPage.aspx")


Hope you this give you an idea to solve your problem

Thanks
Amit

Thanks,
Amit
Please "Mark As Answer " if this post help you.


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend