473,404 Members | 2,187 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

How loop datalist to retrieve textbox value?

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?
Nov 19 '05 #1
2 1943
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" <do**@emailme.com> wrote in message
news:uq**************@TK2MSFTNGP09.phx.gbl...
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?

Nov 19 '05 #2
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" <re*************@monarchmed.com> wrote in message
news:uU**************@TK2MSFTNGP09.phx.gbl...
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" <do**@emailme.com> wrote in message
news:uq**************@TK2MSFTNGP09.phx.gbl...
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?


Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Mark | last post by:
Hi, I have a datalist that contains a textbox as well as a dropdown list. For each single row in the datalist the associated dropdown list can have at least one value What I would like to be...
0
by: Alex | last post by:
Imports System Imports System.Data Imports System.Data.SqlClient Imports System.Web.UI Imports System.Web.UI.WebControls Imports System.Configuration Public Class Main : Inherits Page ...
0
by: Peter Afonin | last post by:
Hello: I've never used the DataList before, and I have a problem now: In the ItemTemplate I put the LinkButton and a TextBox (not databound, I want the user to be able to type in it). Then I...
4
by: Joe Van Meer | last post by:
Hi, Is the datalist meant for one table or can I use it to display information from 2 different tables? Or should I be looking at a datagrid instead? I began my code and kinda ran into a snag...
4
by: Lerp | last post by:
I have a dataset that is made up of info from 2 tables. I have created a relationship between these 2 and have added it to the dataset. My datalist is working perfectly minus one little problem,...
0
by: Xiru | last post by:
I would like to retrieve the value from a DataList on postback. I can read the ItemIndex and values from a child TextBox but not cannot seem to find a way to read a databound item on the datalist....
2
by: Chris Fink | last post by:
This should be relatively simple but I am unable to find an asp:button tag in a datalist footer. I have tried it numerous ways including the FindControl method from the many events that the...
0
by: Chris Fink | last post by:
I am having a problem highlighting a row in a datalist during the itemdatabound event. What is occurring is that a new td row is being wrapped around the datalist item which is highlighted (very...
3
by: Crazy Cat | last post by:
Hi all, I am developing an asp.net 2.0 application in Visual Studio 2005. On my page I have a simple datalist that is bound programmatically to a collection of simple objects. On this page I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.