.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

Dynamic checkobx adding in GridView

Posted By: Ramesh     Posted Date: July 28, 2010    Points:2   Category :ASP.Net
I have added dynamic checkbox in the GridView

I want to check check box is checked or not

If I use objgridrowview.FindControl("Idname",CheckBox)

It shows me error like object reference is not set to instance of object

Responses
Author: Syed Shakeer Hussain             
Posted Date: July 28, 2010     Points: 5   

Hi Ramesh,
use the below code
protected void Gridview_Click(object sender, EventArgs e)

{

for (int i = 0; i < Gridview1.Rows.Count; i++)

{

CheckBox chkb = (CheckBox)Gridview1.Rows[i].Cells[0].FindControl("chk");

if (chkb.Checked)

{

string name = Gridview1.Rows[i].Cells[2].Text;

Response.Write("<br>" + name);

}

}

}


For more inforamtion you can check this article
http://www.dotnetspark.com/kb/639-how-to-get-multiple-selected-values-from.aspx



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