Solved

Databinding and querystring

Posted on 2006-10-24
8
481 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 7

Expert Comment

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

Expert Comment

by:nepali
Comment Utility
0
 
LVL 7

Accepted Solution

by:
nepali earned 250 total points
Comment Utility
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
Comment Utility
Nepali,

It worked!!  Many many thanks for helping.

Regards

Mitesh
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
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…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

772 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

16 Experts available now in Live!

Get 1:1 Help Now