Solved

dynamic binding listview asp.net 3.5

Posted on 2010-08-31
7
481 Views
Last Modified: 2012-06-27
How Can I bind the ID column of my Access Datasource into this code, this as is is static  but I need dynamic
Protected Sub ListView1_ItemDataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListView1.ItemDataBound



        Dim myButtonPrint As Button = CType(ListView1.FindControl("PrintButton"), Button)

        myButtonPrint.PostBackUrl = "PrintableProviderList.aspx?Id=132"

    End Sub

Open in new window

0
Comment
Question by:TonyReba
  • 3
  • 2
  • 2
7 Comments
 
LVL 3

Accepted Solution

by:
omnimaven earned 400 total points
Comment Utility
you can do something like:

myButtonPrint.PostBackUrl = "PrintableProviderList.aspx?Id=" & CType(e.item.DataItem, DataRowView)["ID"].ToString()
0
 
LVL 21

Assisted Solution

by:silemone
silemone earned 100 total points
Comment Utility
you will have to direct cast the  (  object ) from  ByVal sender As Object
as the type that's being passed...and then

and then use the

Textbox text = (Textbox) object;
ID = object.id;
0
 
LVL 21

Expert Comment

by:silemone
Comment Utility
oops...Omni is right...its actually the e.item that is the object
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 3

Expert Comment

by:omnimaven
Comment Utility
I think you need to change the ["ID"] to ("ID"). I am used to C#.
0
 
LVL 9

Author Comment

by:TonyReba
Comment Utility
I get the following errors, where should I place this code ? , right now is on
  Protected Sub ListView1_ItemDataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListView1.ItemDataBound

Errors:
item' is not a member of 'System.EventArgs'.
I
["ID"]
dentifier expected.            
0
 
LVL 9

Author Comment

by:TonyReba
Comment Utility
OK this worked changing the Sub Declaration to

Protected Sub ListView1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ListViewItemEventArgs) Handles ListView1.ItemDataBound
0
 
LVL 9

Author Closing Comment

by:TonyReba
Comment Utility
ty
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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 …
Envision that you are chipping away at another e-business site with a team of pundit developers and designers. Everything seems, by all accounts, to be going easily.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

762 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

15 Experts available now in Live!

Get 1:1 Help Now