Stumped on datagrid.items.count issue

R

Rob

I have a datagrid that is used to enter accruals by cost code. Now the manager of that department wants the cost codes seperated by Catgory and only certain categories are editable. The code below does that however the last row of the the Category "A" insists on displaying the textbox and the last row in B category displasy the label. Any idea where I've gone wrong?

For i As Integer = 0 To grddata.Items.Count - 1
If oDr.Read() Then

Dim txtaccrualamount As System.Web.UI.WebControls.TextBox = grddata.Items(i).FindControl("txtaccrualamount")
Dim lblaccrualamount As System.Web.UI.WebControls.Label = grddata.Items(i).FindControl("lblaccrualamount")

If oDr("CostCodeCategory").ToString = "A" Then

txtaccrualamount.Visible = False

lblaccrualamount.Visible = True
ElseIf oDr("CostCodeCategory").ToString = "B" Then

txtaccrualamount.Visible = True

lblaccrualamount.Visible = False

End If

End If
Next


From http://www.developmentnow.com/g/38_2004_11_0_26_0/dotnet-languages-vb.ht

Posted via DevelopmentNow.com Group
http://www.developmentnow.com
 
J

Jonathan Boivin

I presume that this code is executed after the loading of the grid. If so, I
think you are using two dataset which maybe differs. Is this right ?
Otherwise, add the code which comes before this one so I could have a more
global idea.
 

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

Top