Solved

dynamic binding listview asp.net 3.5

Posted on 2010-08-31
7
498 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
ID: 33571672
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
ID: 33571685
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
ID: 33571694
oops...Omni is right...its actually the e.item that is the object
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 3

Expert Comment

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

Author Comment

by:TonyReba
ID: 33571897
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
ID: 33572114
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
ID: 33572126
ty
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Read about why website design really matters in today's demanding market.
"In order to have an organized way for empathy mapping, we rely on a psychological model and trying to model it in a simple way, so we will split the board to three section for each persona and a scenario and try to see what those personas would Do,…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…

867 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

24 Experts available now in Live!

Get 1:1 Help Now