Solved

Databinding and querystring

Posted on 2006-10-24
8
482 Views
Last Modified: 2008-02-01
Hi,

I have bound a view to a data list.  I'm displaying the information using the following string which i'm sure is familiar to you:

<asp:Label id=lblFirstName runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.FirstName", "{0}") %>'>
                  </asp:Label>

I want to pass the ID of this user via the querystring.  I have tried the following but get errors.

<asp:HyperLink id="Hyperlink2" CssClass="subhead" runat="server" Visible="true" NavigateUrl="../../../ProfileView/tabid/60/default.aspx?<%# DataBinder.Eval(Container, "DataItem.UserID", "{0}") %>">Details</asp:HyperLink>

I assume this isn't correct; would anyone know the correct way to do this?

Thanks
0
Comment
Question by:mitesh114
  • 5
  • 3
8 Comments
 
LVL 7

Expert Comment

by:nepali
ID: 17794443
Hi,
Try this out
you request your page with a querystring say its "aaa".
eg. http://127.0.0.1/TestWeb1/webform1.aspx?aaa=123

and in your aspx page you can add the following to get the value.
      <%# Request.QueryString("aaa")%>

But this is a databinding expression. Hence it will be called or executed only if you call the DataBind() method in your page.
For that you just have to add DataBind(); statement to your page_load method. That's it.
0
 

Author Comment

by:mitesh114
ID: 17794470
Hi Nepali,

I have the databind() expression in my page_load.  the expression <%# DataBinder.Eval(Container, "DataItem.UserID", "{0}") %> works when I place it in labels text parameter but doesn't seem to work with the navigateURL property.

Mitesh
0
 
LVL 7

Expert Comment

by:nepali
ID: 17794654
Ohhh Kaay... for that just replace the "" (double quotes on dataitem.userid and the format specifier "{0}" by single quotes ''

use the following.
<asp:HyperLink id="Hyperlink2" CssClass="subhead" runat="server" Visible="true" NavigateUrl="../../../ProfileView/tabid/60/default.aspx?<%# DataBinder.Eval(Container, 'DataItem.UserID', '{0}') %>">Details</asp:HyperLink>
0
 

Author Comment

by:mitesh114
ID: 17794713
Thanks Nepali,

Here's what it returns though:

http://localhost/dnn_a/UserProfile/tabid/ProfileView/tabid/60/default.aspx?myID=<%#%20DataBinder.Eval(Container,%20'DataItem.UserID',%20'{0}')%20%>

Instead of returning the ID it returns
<%#%20DataBinder.Eval(Container,%20'DataItem.UserID',%20'{0}')%20%>
0
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.

 
LVL 7

Expert Comment

by:nepali
ID: 17794738
oops sorry that will not work.. give me some time i'll work this out...
0
 
LVL 7

Expert Comment

by:nepali
ID: 17794788
0
 
LVL 7

Accepted Solution

by:
nepali earned 250 total points
ID: 17795184
heres ur solution
<asp:HyperLink id="Hyperlink2" CssClass="subhead" runat="server" Visible="true"  NavigateUrl='<%# DataBinder.Eval(Container,"DataItem.UserID", "../../../ProfileView/tabid/60/default.aspx?{0}") %>'>Details</asp:HyperLink>
0
 

Author Comment

by:mitesh114
ID: 17795276
Nepali,

It worked!!  Many many thanks for helping.

Regards

Mitesh
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

Title # Comments Views Activity
asp.net bundle 8 47
Paging GridView 7 49
Visual Studio: built-in keystroke automation 2 47
Where can I ask about my ASP.NET MVC project? 6 19
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…
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 …
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

911 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

17 Experts available now in Live!

Get 1:1 Help Now