TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Nilesh Patil
NA
3k
115.6k
threw an exception of type system nullreferenceexception c#
Nov 17 2017 12:01 AM
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;
}
Reply
Answers (
3
)
How to dynamically add the textbox inputs to table in mvc
if session is off then TempData will work in MVC or not?