Solved

Databinding and querystring

Posted on 2006-10-24
8
485 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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 

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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to filter by key press ? 6 66
ASP.net Markup for Sub Menu 2 65
Query in AngularJS 8 84
Ajax calendar distorted 4 24
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

710 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