Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

datagrid iteration question

Status
Not open for further replies.

Bob2

Programmer
Jul 3, 2000
228
SE
Hi


I try to iterate through a datagrid that have 5 visible items and one that is not visible. I need to both check if there is a value for the hidden value and what that value is (it can be a null value). I currently use this code..





For Each dgi In MyDataGrid.Items

Select Case dgi.ItemType

Case ListItemType.Item, ListItemType.AlternatingItem

'Use CartID to identify what item to delete or update

CartID = MyDataGrid.DataKeys(dgi.ItemIndex)

TextBoxQuantity = CType(dgi.FindControl("intQty"), TextBox)

'TextFileName = CType(dgi.FindControl("lblFileName"), TextBox)





If CType(dgi.FindControl("DeleteFromCartCheckBox"), CheckBox).Checked = True Or (TextBoxQuantity.Text) = 0 Then

'Remove from Cart Code Here





If dgi.FindControl("lblFileName") Is Nothing Then

MyCheck.Text = "doesn't exists"

else

MyCheck.Text = dgi.FindControl("lblFileName").ToString

End If







If there is a value for the hidden (lblFileName) value my code now writtes out "System.Web.UI.WebControls.Label " in the MyCheck.Text.


Now that is not right, what do I have to change to get it to write out the value of the label?


Regards


M
 
Change:
MyCheck.Text = dgi.FindControl("lblFileName").ToString
to:
MyCheck.Text = ctype(dgi.FindControl("lblFileName"),Label).Text



Then Microsoft said, "Let there be .net"; and there was .net.


Greetings, Harm Meijer
 
Ahhh


Of course you're right, I can't believe I didn't see that. Thanks for open my eys ;-)


Regards

M
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top