473,395 Members | 1,677 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Accessing a control (eg. Label) inside a datgrig


Hello there,

I need to show or hide a label cotrol in one of the cell of my datagrid.

I tried the following:
----------
DataGridItem item = MyDataGrid.Items[ MyDataGrid.EditItemIndex];

Label status= (Label) item.FindControl("MyGridStatus");

----------

But i get the following :

Object reference not set to an instance of an object.

when i do the following: status.Text = "My datagrid status"

I do this in the "update commande handler...

Can anyone help me with this issue?

Thanks in advance

Jensen


Nov 18 '05 #1
2 944
the way you are trying to access is correct but the problem you are getting
that error is beac its not able to locate the label control.
try to debug. probably the label is not present or try to loop thru the
items in the datagrid.

HTH
Regards
Ashish M Bhonkiya

"bredal Jensen" <br******@jensen.dk> wrote in message
news:OA**************@TK2MSFTNGP12.phx.gbl...

Hello there,

I need to show or hide a label cotrol in one of the cell of my datagrid.

I tried the following:
----------
DataGridItem item = MyDataGrid.Items[ MyDataGrid.EditItemIndex];

Label status= (Label) item.FindControl("MyGridStatus");

----------

But i get the following :

Object reference not set to an instance of an object.

when i do the following: status.Text = "My datagrid status"

I do this in the "update commande handler...

Can anyone help me with this issue?

Thanks in advance

Jensen



Nov 18 '05 #2
Right... I' d missed the runat="server" in the control definiton in my aspx
page.

Many thanks

"Ashish M Bhonkiya" <bh******@hotmail.com.nospam> wrote in message
news:OW**************@TK2MSFTNGP11.phx.gbl...
the way you are trying to access is correct but the problem you are getting that error is beac its not able to locate the label control.
try to debug. probably the label is not present or try to loop thru the
items in the datagrid.

HTH
Regards
Ashish M Bhonkiya

"bredal Jensen" <br******@jensen.dk> wrote in message
news:OA**************@TK2MSFTNGP12.phx.gbl...

Hello there,

I need to show or hide a label cotrol in one of the cell of my datagrid.

I tried the following:
----------
DataGridItem item = MyDataGrid.Items[ MyDataGrid.EditItemIndex];

Label status= (Label) item.FindControl("MyGridStatus");

----------

But i get the following :

Object reference not set to an instance of an object.

when i do the following: status.Text = "My datagrid status"

I do this in the "update commande handler...

Can anyone help me with this issue?

Thanks in advance

Jensen




Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: John Knoop | last post by:
Hi all I have a page that contains a label (<asp:label id="lbl" runat="server">). Further down in that same page, I include the contents of a different page using Server.Execute. Now, I need...
1
by: Kristoffer Arfvidson | last post by:
<asp:DataGrid id="DataGrid1" runat="server" AllowPaging="True" AutoGenerateColumns="False" Font-Names="Verdana, Arial, Helvetica, sans-serif" AllowCustomPaging="True" GridLines="Horizontal">...
1
by: Miguel Dias Moura | last post by:
Hello, I have a GridView in my page with a TemplateField and an Asp Label inside it. I need to access that Label in runtime and change the field to which it is binded. Can someone please...
3
by: Paul | last post by:
I am using Visual Studio.net 2005 (and asp.net 2.0) Let's say that in a Web Project, I have created a (Dataset?) called SomeDataset.xsd. On it I have a TableAdapter called SomeTableTableAdapter...
4
by: John Kotuby | last post by:
Hi all, I am using a Repeater in conjunction with a SQLDatasource and SQL Server. One of the controls in the repeater is a HyperlLink as follows: <asp:HyperLink...
1
by: HockeyFan | last post by:
protected void gvAuthorizedSigners_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "EmptyInsert") { odsAuthorizedSigners.Insert(); return; } if (e.CommandName...
4
by: imranabdulaziz | last post by:
Dear All, I am using asp.net2.0, C#, sql2005 using Visual studio 2005 Let Me explain the scenario I have checkboxlist containg 15 field. Based on no of checked field . I created...
0
by: TisMe | last post by:
Hi All, I have a problem that I am struck on, can you help? 1) I drag labelX onto the page 2) Create a new class 'myClass' which inherits system.web.ui.page (Outside of the _default class for...
3
by: Nathan Sokalski | last post by:
I have a validator that I wrote by inheriting from BaseValidator. At certain points in the code, I need to access other controls on the page containing the validator. I have the IDs of these...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.