473,791 Members | 3,216 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1993
foreach (DataListItem item in myDataList.Item s)
{
myTextBox = item.FindContro l ("textboxId" );
}

Note, that the textbox in the item template should have runat="server".

Eliyahu

"VB Programmer" <do**@emailme.c om> wrote in message
news:uq******** ******@TK2MSFTN GP09.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.It ems
Dim CartId As Label = CType(i.FindCon trol("Label1"), Label)
Dim Qty As TextBox = CType(i.FindCon trol("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.co m> wrote in message
news:uU******** ******@TK2MSFTN GP09.phx.gbl...
foreach (DataListItem item in myDataList.Item s)
{
myTextBox = item.FindContro l ("textboxId" );
}

Note, that the textbox in the item template should have runat="server".

Eliyahu

"VB Programmer" <do**@emailme.c om> wrote in message
news:uq******** ******@TK2MSFTN GP09.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
2010
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 able to do is when a single update button is clicked the textbox value along with the associated dropdown value is printed for each row in the datalist. The number of rows in the datalist can vary. Here is my Datalist code
0
1767
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 Private strConn As String =
0
1603
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 try to retrieve the value of the textbox by pressing the Linkbutton, like this, pretty much like I do it in Datagrid: Private Sub MyList_ItemCommand(ByVal source As Object, ByVal e As
4
2482
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 where my last two columns I am displaying are ID fields, one for clientid and the other for empid. What I would really like is to display their actual names instead of the ids.
4
1185
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, the very last field in my itemtemplate is an ID field from the child table. I would like to display the Name of the company as opposed to the ID. Is there a way to do this? I have read that there is a method called GetChildRows, but I am unsure...
0
1451
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. Here is some code to help clarify. I want to display the items from a shopping list that had a unit number filled in a textbox next to the product: ' Create a holding place for list items with units filled in Dim itemsUnits As New DataSet Dim...
2
8738
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 DataList exposes and the result is always null (I've determined the OnItemDataBound event will not find the footer controls). I understand that I have to navigate the datalist object tree, but I feel like it is a guessing game and am hesitant to do it...
0
1431
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 small), but the actual row that I want to be highlighted is not. Style is being applied to the wrong td row. Following is my code for webform: <asp:datalist ID="dlSmartKeys" Width="700" CellPadding="0" CellSpacing="0" Runat="server">...
3
2811
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 need to control the visibility of a textbox based on a dropdown selection in the datalist's edititem template. To do this, I registered a client script block function and attached a client side handler for the dropdownlist's onchange event in the...
0
9517
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10207
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10156
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9030
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7537
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6776
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5559
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3718
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2916
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.