Solved

Collect datakeys from datalist when looping thorugh rows

Posted on 2008-06-10
2
1,258 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
ID: 21754592
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
ID: 31465840
thanks i should have seen that
0

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

803 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