asp.net 2.0 cant count?! help!

A

Andy B

I have a detailsView (replaced the formview with it) thinking it would help
me fix my control access in a formview problem. Well, I don't think .net
knows how to count. Here is what I have:

I am trying to display the value of a certain cell in a label control. Say,
NewsId for my example. In this example, NewsId should be 14. I took this
line and used it to find out how many rows there were:
DateConfirmLabel.Text = EditNewsForm.Rows.Count.ToString();



I got 4. Ok no big deal. I want row 2, cell 2, so I wrote this:



DateConfirmLabel.Text = EditNewsForm.Rows[1].Cells.Count.ToString();



When I run it to see how many cells are in the row, I get index out of range
error when running the page. I found that it was the Rows[1] that was making
the problem. Any idea why this happens?
 
B

bruce barker

you are probably trying to access the row before it has been added.


-- bruce (sqlwork.com)
 
A

Andy B

Never thought of that. I have an interesting question then. I have the
detailsView inside step 1 of a wizard. I need to transfer these BoundFields
into labels on step2 of the same wizard. Where would I put my code?


bruce barker said:
you are probably trying to access the row before it has been added.


-- bruce (sqlwork.com)


Andy B said:
I have a detailsView (replaced the formview with it) thinking it would
help
me fix my control access in a formview problem. Well, I don't think .net
knows how to count. Here is what I have:

I am trying to display the value of a certain cell in a label control.
Say,
NewsId for my example. In this example, NewsId should be 14. I took this
line and used it to find out how many rows there were:
DateConfirmLabel.Text = EditNewsForm.Rows.Count.ToString();



I got 4. Ok no big deal. I want row 2, cell 2, so I wrote this:



DateConfirmLabel.Text = EditNewsForm.Rows[1].Cells.Count.ToString();



When I run it to see how many cells are in the row, I get index out of
range
error when running the page. I found that it was the Rows[1] that was
making
the problem. Any idea why this happens?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,297
Messages
2,571,529
Members
48,240
Latest member
เพิ่มไลค์|LikePro

Latest Threads

Top