Skip to content

Asp.net: How to retrive the DataGrid checkbox value

Asked Feb 23, 2006, 4:28 PM EST1 answer
Share
LinkedInX
hi friends,


     I need One solution ,help me .
------------------------------------------------
Java
CheckBox gold=(CheckBox)e.Item.FindControl("ckGold");
CheckBox silver=((CheckBox)e.Item.FindControl("ckSilver"));
string txt=((TextBox)e.Item.FindControl("txt1")).Text;;


Response.Write(((CheckBox)e.Item.FindControl("ckGold")).Text);

Response.Write(((CheckBox)e.Item.FindControl("ckGold")).Text);

if(gold.Checked==true)

silver.Checked=false;

else if(silver.Checked==true)

gold.Checked=false;

 else

Page.RegisterStartupScript("Statrup","<script>alert('Please Select Any One Status.....');</script>");

------------------------------------------------------
Above code to be displayed one error:'Object Reference to be set an instance of an object'

What's the solution this?

                                                        Thank u

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    Hi, When you iterate through the datagrid items you should skip the header row becuase in header row you will not find checkbox or textbox. So just put IF condition to check header row, i.e. if header row then skip your code execution. Happy .Neting
    0