Stumped on datagrid.items.count issue

  • Thread starter Thread starter Rob
  • Start date Start date
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
 
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.
 
Back
Top