?
Solved

Collect datakeys from datalist when looping thorugh rows

Posted on 2008-06-10
2
Medium Priority
?
1,266 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 22

Accepted Solution

by:
prairiedog earned 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

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