Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
3
Reply
threw an exception of type system nullreferenceexception c#
Nilesh Patil
Nov 17 2017 12:01 AM
199
Reply
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>"
;
//// Here is error
}
i = i + 1;
}
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
3
)
Next Recommended Forum
How to dynamically add the textbox inputs to table in mvc
if session is off then TempData will work in MVC or not?