473,782 Members | 2,507 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Retrieve DataList Value

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 itemUnitsTable As DataTable
Dim itemUnitsRow As DataRow
' Add new table
itemUnitsTable =
itemsUnits.Tabl es.Add("Purchas eListItems")

' Define Columns
With itemUnitsTable
.Columns.Add("l ist_item_id", GetType(System. Int16))
.Columns.Add("l ist_item_name", GetType(System. String))
.Columns.Add("p urchase_list_it em_units",
GetType(System. Int16))
End With
' Fetch list items
For Each aItem As DataListItem In DataList1.Items
' Find nested datalist control for list items
Dim bList As DataList = aItem.FindContr ol("DataList2" )

' Iterate through list items to create the new dataset
For Each bItem As DataListItem In bList.Items
Dim pTextBox As TextBox =
bItem.FindContr ol("Textbox1")
Dim productId As Integer = bItem.ItemIndex
' ****** HERE IS WHERE I NEED HELP **********
'Dim productName As String = bItem.DataItem
'Dim productName As String =
DataBinder.Eval (bItem.DataItem , "Product")
' *************** *************** ***************

If pTextBox.Text = "" Then pTextBox.Text = 0
Dim productUnits As Integer = CInt(pTextBox.T ext)
If productUnits > 0 Then
' Create a new row to store values
itemUnitsRow = itemUnitsTable. NewRow
With itemUnitsRow
.Item("list_ite m_id") = productId
.Item("list_ite m_name") = productName
.Item("purchase _list_item_unit s") =
productUnits
End With
' Now add rows to DataTable
itemUnitsTable. Rows.Add(itemUn itsRow)
End If
Next
Next
' Bind selected list items for confirmation
DataList3.DataS ource = itemsUnits
DataList3.DataB ind()
Nov 18 '05 #1
0 1450

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
4
3097
by: V. Jenks | last post by:
What seems like a simple thing is apparently not so straightforward? I have a datalist. Inside of that datalist is an <itemtemplate> secion which contains other server controls such as a label, a radiobuttonlist, etc. I'm driving myself insane trying to figure out how to get
2
8737
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...
3
3126
by: webserverpete | last post by:
I am new to ASP.NET in general, but I do have experience with classic ASP. I am using a DataList control with a hidden value to submit to a different page, however I do not know how to get to that hidden value. Here is my DataList control code: <asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1" RepeatColumns="4"> <ItemTemplate> <%#DataBinder.Eval(Container.DataItem, "itemname")%> <br>...
6
9595
by: Paul | last post by:
I am trying to use a DataList and the ItemTemplate. I am binding the Datalist to a SQL query that gives me a list of Items with a Parent Category. I want to loop through all the items, but only print the Parent Category once, regardless of how many child items are in it. So my perfect output would look something like:
2
1993
by: VB Programmer | last post by:
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?
1
1548
by: William Oliveri | last post by:
Hi all, I"ve been trying to retrieve the names of each selected items in a Datalist. So I've been trying to loop through each entry in the datalist to retrieve the name of each entry. I cannot find the correct syntax to do this. Can anyone share how to do this? thanks in advance.
1
2664
by: AJ | last post by:
Hi all, With the following code in mind : <asp:DataList ID="dlOne" DataKeyField="myField1" DataSource="<%# GetDataSource1()" Runat="server"> <ItemTemplate> Output Value Here! <asp:DataList ID="dlTwo" DataKeyField="myField2" DataSource="<%# GetDataSource2(?,?)" Runat="server">
1
7940
by: terminul | last post by:
Hi I have a datalist which loops through the categories and within the datalist I have a CheckBoxList which are bound on the DataList's OnItemDataBound. The only problem I have is retrieving the values that have been checked when the user submits the form. This code works as far as presentation goes but I can't seem to retrieve the checked values in the various checkboxlists that have been generated on the datalist's OnItemDataBound ...
0
9641
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
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
10313
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10080
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
9944
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8968
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...
0
5378
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4044
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2875
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.