Solved

Collect datakeys from datalist when looping thorugh rows

Posted on 2008-06-10
2
1,251 Views
Last Modified: 2011-10-03
hi

i have made a datalit that shows a list of items with a text box next to each item. i want to be able to enter a value into each text box and then have the user click one button "Update all" and it to then update all the record that are shown.

each row is one record.

i have started to do this by using the code below to loop thorugh each row and collect the text box.

i also need to collect the datakey whch is defined in the datalist so that i can update the correct record.

i have used this code from a tutorial online but now i am unable to get it to work
Protected Sub SaveAll_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SaveAll.Click

        Dim dlitem As DataListItem

        Dim installed As TextBox

        Dim itemID As Integer
 

        For Each dlitem In DataList1.Items

            installed = CType(dlitem.FindControl("Installedtext"), TextBox)

            itemID = Convert.ToInt32(DataList1.DataKeys[Items.itemindex])
 

        Next
 

    End Sub

Open in new window

0
Comment
Question by:bolt81
2 Comments
 
LVL 22

Accepted Solution

by:
prairiedog earned 500 total points
Comment Utility
This line is not right:
itemID = Convert.ToInt32(DataList1.DataKeys[Items.itemindex])

VB.NET does not support square brackets. Change it to:
itemID = Convert.ToInt32(DataList1.DataKeys(dlitem.ItemIndex))
0
 
LVL 1

Author Closing Comment

by:bolt81
Comment Utility
thanks i should have seen that
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Gridview Edit Row 10 43
Pick image, show data 4 33
Why is "packages element is not declared"? 2 34
Re-position the objects 7 46
In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now