Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Databinding and querystring

Posted on 2006-10-24
8
Medium Priority
?
488 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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 1000 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

718 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