473,396 Members | 1,938 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,396 software developers and data experts.

Identifying Rows

Ben
In C#, I have a GridView that bounds to a DataView.
When the user click a certain button, I want it to go through the
gridview rows and update some object based on an ID.

The ID should be invisible... so I put a <LABELin one of the cells
and trying to access it via FindControl... but it's always returning
null.

I even made each LABEL have it's own ID (being equal to MonitorID1, 2,
3... etc), it's still not getting it.. here's a snippet, maybe someone
has ideas on what's wrong?
protected void btnSetMaintenance_Click(object sender, EventArgs e)
{
int iCount = 0;
foreach (GridViewRow gvr in gridIssues.Rows)
{
Label lbl =
(Label)gvr.Cells[1].FindControl("MonitorID" + iCount.ToString());

if(lbl != null)
Response.Write(lbl.Text + "<BR>");
else
Response.Write("not found (" + gvr.Cells[1].Text +
iCount.ToString() + "<BR>");

iCount++;
}
}
Thank you!
Dec 28 '07 #1
3 1011
"Ben" <be******@gmail.comwrote in message
news:22**********************************@x69g2000 hsx.googlegroups.com...
In C#, I have a GridView that is bound to a DataView.
When the user clicks a certain button, I want it to go through the
GridView rows and update some object based on an ID.
Is the button that the user clicks outside the GridView?

Is the object to be updated also outside the GridView?
Label lbl = (Label)gvr.Cells[1].FindControl("MonitorID" +
iCount.ToString());
Set a breakpoint on the line above and, in the Immediate window, type
gvr.Cells[1].Controls.Count and press Enter - how many controls are in that
cell?

Then, still in the Immediate window, type gvr.Cells[1].Controls[0] and press
Enter - what do you see?

Repeat for the remaining controls in that cell...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Dec 29 '07 #2
"Ben" <be******@gmail.comwrote in message
news:0f**********************************@z26g2000 pre.googlegroups.com...
Thanks you very much for the responses.... the immediate window showed
this while debugging...any ideas why it's finding 0 controls? you can
see the Text of the cell holds the label:
Looks very much like you didn't actually add a label control to the cell in
question, but rather you added the rendered text of a label as the cell's
Text property...

That is why gvr.Cells[1].Controls.Count is returning a value of zero,
because there aren't any actual controls in the cell...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Dec 30 '07 #3
"Phil H" <go****@philphall.me.ukwrote in message
news:d1**********************************@t1g2000p ra.googlegroups.com...
(In deference to Mark)
There's no need at all to hold me in any sort of deference - if you think
I'm wrong, then please say so... :-)
I've noticed that a lot of posters on this forum fail to differentiate
properly
between the underlying data from what is displayed in databound controls.
I understand what you're saying, but in this case it didn't seem to me that
the OP actually wanted to *change* the GridView's underlying data, but
rather to display additional metadata depending on the underlying data...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Dec 30 '07 #4

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

Similar topics

5
by: Mark | last post by:
I have an application that uses PHP to access a MySQL table and extract rows which match the user's search entry. Data from the matching rows are loaded into an HTML selection list, and the user...
1
by: David | last post by:
I know that identifying the user IP address with HTTP_SERVER_VARS; is reliant on the browser agent but I have stumpled upon the following code which I have tried to understand but failed! ...
1
by: Hafez | last post by:
Hi All The problem:!! I want to create a temp table which is common between different users so that each user could select his rows and print them without printing others selection. All clients...
0
by: Jenny - | last post by:
> I understand that ObjID of LOCKtag recognizes each individual row locked by >a row level lock. BUt i have noticed that if i lock 2 different rows of the >same table they have the same blkno. is...
3
by: Christopher Weaver | last post by:
I want to set a value in a specific field in the current row of a DataSet. This seems like the most basic thing to do but I can't find the syntax for identifying the current row. IOW, I can do...
9
by: kw | last post by:
What is the proper way to get the element ID for a client script? For example, suppose in the WebControl: TextBox t=new TextBox; t.ID=this.ClientID+"X"; .... Then elsewhere we want to access...
4
by: Ed L. | last post by:
I am trying to identify tables with significant diskspace "leakage" due to in appropriately low max_fsm_pages settings. I can see the results of VACUUM ANALYZE VERBOSE output counts of tuples and...
1
by: negmat | last post by:
Guys, I have a table with a single VARCHAR column. The COLLATION for this column is SQL_Latin1_General_CP1_CI_AS. Some of the values contain 'greek' or other European language characters (e.g....
10
by: Frankie | last post by:
It appears that System.Random would provide an acceptable means through which to generate a unique value used to identify multiple/concurrent asynchronous tasks. The usage of the value under...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.