asp.net 2.0 cant count?! help!
asp.net 2.0 cant count?! help!
am 16.01.2008 19:46:43 von 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?
RE: asp.net 2.0 cant count?! help!
am 16.01.2008 21:33:00 von brucebarker
you are probably trying to access the row before it has been added.
-- bruce (sqlwork.com)
"Andy B" wrote:
> 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?
>
>
>
>
>
>
>
>
>
Re: asp.net 2.0 cant count?! help!
am 16.01.2008 21:51:20 von 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" wrote in message
news:ED9E3F0E-AEC9-42AE-9915-C0A24329057A@microsoft.com...
> you are probably trying to access the row before it has been added.
>
>
> -- bruce (sqlwork.com)
>
>
> "Andy B" wrote:
>
>> 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?
>>
>>
>>
>>
>>
>>
>>
>>
>>