Solved

Databinding and querystring

Posted on 2006-10-24
8
483 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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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
 
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

860 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