Re: How loop datalist to retrieve textbox value?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



I tried looping thru the datalist like this:

For Each i As DataListItem In Me.DataList1.Items
Dim CartId As Label = CType(i.FindControl("Label1"), Label)
Dim Qty As TextBox = CType(i.FindControl("txtQty"), TextBox)
Response.Write(CartId.Text & ":" & Qty.Text & "<br>")
Next

Qty gets filled properly. But, CartId ALWAYS comes up blank even though I
visually can see that there's a .text value. Any ideas why?

Thanks.

"Eliyahu Goldin" <removemeegoldin@xxxxxxxxxxxxxx> wrote in message
news:uUyt28O6FHA.3136@xxxxxxxxxxxxxxxxxxxxxxx
> foreach (DataListItem item in myDataList.Items)
> {
> myTextBox = item.FindControl ("textboxId");
> }
>
> Note, that the textbox in the item template should have runat="server".
>
> Eliyahu
>
> "VB Programmer" <dont@xxxxxxxxxxx> wrote in message
> news:uqg9RTL6FHA.1416@xxxxxxxxxxxxxxxxxxxxxxx
>> I have a datalist for a shopping cart summary. Each data "row" has a
>> text
>> box where they can enter a quantity. How do I loop thru the entire
> datalist
>> to figure out the total shopping cart price?
>>
>>
>
>


.