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
Valerie Meunier
NA
693
81.7k
trying to get text of a label in itemTemplate of a gridview
Apr 16 2021 12:52 PM
Hi
I'm trying to get the text of a label located in a ItemTemplate of a gridview.
The error is: Object reference not set to an instance of an object
Thanks for help.
V
Here the code:
protected
void
Button2_Click(
object
sender, System.EventArgs e)
{
Label nal;
foreach
(GridViewRow row
in
GridView1.Rows)
{
nal = (Label)GridView1.FindControl(
"naaml"
);
}
...
a = nal.Text;
//(Object reference not set to an instance of an object)
Here the aspx-code:
<asp:GridView ID=
"GridView1"
runat=
"server"
... />
<asp:TemplateField >
<EditItemTemplate>
<asp:TextBox ID=
"naam"
runat=
"server"
Text=
'<%# Bind("naam") %>'
></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID=
"naaml"
runat=
"server"
Text=
'<%# Bind("naam") %>'
></asp:Label>
</ItemTemplate>
</asp:TemplateField>
...
</asp:GridView>
Reply
Answers (
4
)
Custom search to filter different records in asp.net mvc
Design & develop a web application to maintain records of students.