Hello,
 
 
I am use repeater control and i that i have a label so i am assign value to this label in code behind but system gives error  threw an exception of type system nullreferenceexception c#
 
 
 
This is my aspx code
- <asp:Repeater ID="Repeater1" runat="server">  
- <HeaderTemplate>  
- <table>  
- </HeaderTemplate>  
- <ItemTemplate>  
- <tr>  
- <td>  
- <asp:Label ID="lbldata" runat="server"></asp:Label>  
- </td>  
- </tr>  
- </ItemTemplate>  
- <FooterTemplate>  
- </table>  
- </FooterTemplate>  
- </asp:Repeater>  
And this is Code behind:-
- DataTable dt_OwnerFilter = new DataTable();  
- Label r1 = (Label)Page.FindControl("lbldata");  
- dt_OwnerFilter = bl.BL_FetchOwnerInfo(bo);  
- pgsource.DataSource = dt_OwnerFilter.DefaultView;  
- lblfetchdata.Text = string.Empty;  
- int i = 1;  
- foreach (DataRow dRow in dt_OwnerFilter.Rows)  
- {  
- if (dt_OwnerFilter.Rows.Count > 0)  
- {  
- string htmlcode = "";  
- htmlcode = "<a class='btn btn-primary' onclick='fnShow(" + dRow["PropertyDetailsId"] + ")'> " + i + "</a>";  
- r1.Text += htmlcode + "<br>";   
- }  
- i = i + 1;  
- }