Click here to Skip to main content
15,886,774 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Label l1 = (Label)GridView1.Rows[0].FindControl("Label1");
            RadioButtonList rbl = (RadioButtonList)GridView1.Rows[0].FindControl("RadioButtonList1");
            
            ((Dictionary<Int32, string>)Session["res"])[Int32.Parse(l1.Text.TrimEnd('.'))] = rbl.SelectedValue;


What I have tried:

how to create an instance for the code
Posted
Comments
MiteshUmta 5-Apr-18 11:37am    
above code is for accessing the control from gridview row. there is no need to create instance.
Member 13764464 5-Apr-18 11:39am    
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:


Line 94: RadioButtonList rbl = (RadioButtonList)GridView1.Rows[0].FindControl("RadioButtonList1");
Line 95:
Line 96: ((Dictionary<Int32, string>)Session["res"])[Int32.Parse(l1.Text.TrimEnd('.'))] = rbl.SelectedValue;
Line 97:
Line 98: try
F-ES Sitecore 5-Apr-18 11:49am    
Something you reference is "null", so that might be Session["res"], l1 or rbl. We can't run your code so we can't know, you'll need to debug to find out. Once you've found out you then need to work out why it is null and what to do when it's null...again something we can't know as we don't know your business rules.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900