Hi, The simplest way to get the value of a cell is using the row and column numbers: val = MyDataList.Items(Y).Cells(X).Text Y = Item (row) number (starting at zero) X = Column number (starting at zero) Now this assumes that that Datalist cell contains just
plain text. If that cell contains any other controls, such as a Label control, TextBox (or anything else), you'll need to use the .Controls() collection of that cell. You'll also need to know how many controls are in that cell, which control you want, and
the type of the control. For example, if the first control in the cell is a Label control, it would look like this: Dim myLabel As Label myLabel = CType(MyDataList.Items(Y).Cells(X).Controls(0), Label) val = myLabel.Text Hope that helps! Datagrid Girl
Thanks Datagirdgirl! Actually, I am using the following code to retrieve values For Each dlItem In detailsgrid.Items ' reference the TextBox Dim txtItems As TextBox = CType(dlItem.FindControl("item_received"), TextBox) ' Grab the value item_recieved = txtItems.Text
' Get the order number from DataKeys order_num = detailsgrid.DataKeys(dlItem.ItemIndex).ToString() I have problem with the line below... ================================= order_line_num = detailsgrid.dlItem(1).Cells(0).Text ==================================
Yaheya Quazi
Director, Admin. Comp. & Systems
University of California, Merced
Error message is in this line order_line_num = detailsgrid.dlItem(1).Cells(0).Text Error Message is ... BC30456: 'dlItem' is not a member of 'System.Web.UI.WebControls.DataList'.
Yaheya Quazi
Director, Admin. Comp. & Systems
University of California, Merced
There is no DataList property called "dlItem", which is how you're trying to use it. dlItem already represents a particular DataListItem, as you've coded it here: For Each dlItem In detailsgrid.Items So, you can just use the .Cells() collection of that DataListItem
directly, like so: order_line_num = dlItem.Cells(0).Text Hope that helps, Datagrid Girl
Ok, first of all, you seem to be mixing DataList and Datagrid code (which incidentally is the same mistake I made--the code I gave you using the .Cells collection only applies to Datagrids). A BoundColumn is only applicable inside an 's collection, which doesn't
apply here. To get all of these values out of your ItemTemplate, you'll need to do one of either of two things: 1) Assign each of your tags an ID, and make them runat="server" so that you'll be able to refer to them in server-side code: Dim TD as TableCell
TD = CType(dlItem.FindControl("order_line_num"), TableCell) val = TD.Text OR: 2) Place your values inside Label controls, and refer to those Label controls in your server code: Dim myLabel as Label myLabel = CType(dlItem.FindControl("order_line_num"), Label)
val = myLabel.Text
yaheya
Participant
1635 Points
340 Posts
Simple question
Aug 04, 2003 06:15 PM|LINK
Director, Admin. Comp. & Systems
University of California, Merced
datagridgirl
Contributor
4417 Points
849 Posts
ASPInsiders
Re: Simple question
Aug 04, 2003 08:41 PM|LINK
yaheya
Participant
1635 Points
340 Posts
Re: Simple question
Aug 04, 2003 08:55 PM|LINK
Director, Admin. Comp. & Systems
University of California, Merced
datagridgirl
Contributor
4417 Points
849 Posts
ASPInsiders
Re: Simple question
Aug 04, 2003 09:14 PM|LINK
yaheya
Participant
1635 Points
340 Posts
Re: Simple question
Aug 04, 2003 09:27 PM|LINK
Director, Admin. Comp. & Systems
University of California, Merced
datagridgirl
Contributor
4417 Points
849 Posts
ASPInsiders
Re: Simple question
Aug 04, 2003 09:32 PM|LINK
yaheya
Participant
1635 Points
340 Posts
Re: Simple question
Aug 04, 2003 09:37 PM|LINK
Director, Admin. Comp. & Systems
University of California, Merced
datagridgirl
Contributor
4417 Points
849 Posts
ASPInsiders
Re: Simple question
Aug 04, 2003 09:45 PM|LINK
yaheya
Participant
1635 Points
340 Posts
Re: Simple question
Aug 04, 2003 09:56 PM|LINK
Director, Admin. Comp. & Systems
University of California, Merced
datagridgirl
Contributor
4417 Points
849 Posts
ASPInsiders
Re: Simple question
Aug 04, 2003 10:07 PM|LINK