asp.net 2.0 cant count?! help!

  • Thread starter Thread starter Andy B
  • Start date Start date
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?
 
you are probably trying to access the row before it has been added.


-- bruce (sqlwork.com)
 
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?
 
Back
Top