473,465 Members | 1,489 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Dynamic QueryString!

Hi all,

I am wanting to url the HyperLink server control in a datagrid.
I am trying to append the id field of the datagrid to the end of the
navigate url.
The code below is causing a problem.

<asp:HyperLink ID="lnkArea" NavigateUrl="index.aspx?aid=<%#
Container.DataItem("bsc_assmnt_area_id")%>" Runat="server"><%#
Container.DataItem("name")%></asp:HyperLink>

Can anyone enlighten me and let me know how to fix this?

Cheers,
Adam

Nov 19 '05 #1
4 1095
Hi Adam,

I don't have the code I used to use in front of me. I think I put a
"Public" function in my code behind. Then here:

NavigateUrl="index.aspx?aid=<%# Container.DataItem("bsc_assmnt_area_id")%>"

I did this:

NavigateUrl="<%#
MyPublicFunction(Container.DataItem("bsc_assmnt_ar ea_id"))%>"

Then I would have MyPublicFunction return the whole URL "index.aspx?aid=10".
The function would be of type string and receive the dataitem as a string or
integer. You may have to do a CStr or CInt around the Container.DataItem
function. Another thing this allowed me to do at the time was switch that
URL on the fly which I needed to do depending on the user's security level.
Good luck! Ken.

--
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight
If you sign up under me and need help, email me.
"Adam Knight" <de*@brightidea.com.au> wrote in message
news:e6**************@TK2MSFTNGP14.phx.gbl...
Hi all,

I am wanting to url the HyperLink server control in a datagrid.
I am trying to append the id field of the datagrid to the end of the
navigate url.
The code below is causing a problem.

<asp:HyperLink ID="lnkArea" NavigateUrl="index.aspx?aid=<%#
Container.DataItem("bsc_assmnt_area_id")%>" Runat="server"><%#
Container.DataItem("name")%></asp:HyperLink>

Can anyone enlighten me and let me know how to fix this?

Cheers,
Adam

Nov 19 '05 #2
What is the behavior you see ?

I suspect the problem is that you can't embed such an expression inside a
literal string. Try :

NavigateUrl='<%# "index.aspx?aid=" &
Container.DataItem("bsc_assmnt_area_id")%>'

--

"Adam Knight" <de*@brightidea.com.au> a écrit dans le message de
news:e6**************@TK2MSFTNGP14.phx.gbl...
Hi all,

I am wanting to url the HyperLink server control in a datagrid.
I am trying to append the id field of the datagrid to the end of the
navigate url.
The code below is causing a problem.

<asp:HyperLink ID="lnkArea" NavigateUrl="index.aspx?aid=<%#
Container.DataItem("bsc_assmnt_area_id")%>" Runat="server"><%#
Container.DataItem("name")%></asp:HyperLink>

Can anyone enlighten me and let me know how to fix this?

Cheers,
Adam

Nov 19 '05 #3
I've seen such databinding reporting "Server tag is not well formed" if
databinding expression <%#....%> was eclosed within double quotes ("<%#....
%>") instead of single ones ('<%#....%>').

Maybe it could help!
Hrvoje


"Adam Knight" <de*@brightidea.com.au> wrote in message
news:e6**************@TK2MSFTNGP14.phx.gbl...
Hi all,

I am wanting to url the HyperLink server control in a datagrid.
I am trying to append the id field of the datagrid to the end of the
navigate url.
The code below is causing a problem.

<asp:HyperLink ID="lnkArea" NavigateUrl="index.aspx?aid=<%#
Container.DataItem("bsc_assmnt_area_id")%>" Runat="server"><%#
Container.DataItem("name")%></asp:HyperLink>

Can anyone enlighten me and let me know how to fix this?

Cheers,
Adam

Nov 19 '05 #4
Adam
Ken's solution would be handy and its more flexible but
Patrice's solution too would work since embedding such an expression
inside a literal string won't work
Make sure the NaviageURL looks like this = '<% %>'
with single quotes
Hope that helps
Patrick


"Ken Dopierala Jr." <kd*********@wi.rr.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi Adam,

I don't have the code I used to use in front of me. I think I put a
"Public" function in my code behind. Then here:

NavigateUrl="index.aspx?aid=<%# Container.DataItem("bsc_assmnt_area_id")%>"
I did this:

NavigateUrl="<%#
MyPublicFunction(Container.DataItem("bsc_assmnt_ar ea_id"))%>"

Then I would have MyPublicFunction return the whole URL "index.aspx?aid=10". The function would be of type string and receive the dataitem as a string or integer. You may have to do a CStr or CInt around the Container.DataItem
function. Another thing this allowed me to do at the time was switch that
URL on the fly which I needed to do depending on the user's security level. Good luck! Ken.

--
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight
If you sign up under me and need help, email me.
"Adam Knight" <de*@brightidea.com.au> wrote in message
news:e6**************@TK2MSFTNGP14.phx.gbl...
Hi all,

I am wanting to url the HyperLink server control in a datagrid.
I am trying to append the id field of the datagrid to the end of the
navigate url.
The code below is causing a problem.

<asp:HyperLink ID="lnkArea" NavigateUrl="index.aspx?aid=<%#
Container.DataItem("bsc_assmnt_area_id")%>" Runat="server"><%#
Container.DataItem("name")%></asp:HyperLink>

Can anyone enlighten me and let me know how to fix this?

Cheers,
Adam


Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: CanoeGuy | last post by:
I have been trying for the last two weeks to display a dynamic DataGrid. The data that I'm pulling from a SQL Server DB will have whole columns that will be either NULL or 0. I want to display...
6
by: 35th Ave Media | last post by:
Hello, I have about 60+ pages that I need to insert a MAILTO: tag so people can email the page using their email client. The body of the message is going to be the URL of that page. Using ASP,...
7
by: CanoeGuy | last post by:
I have been trying for the last two weeks to display a dynamic DataGrid. The data that I'm pulling from a SQL Server DB will have whole columns that will be either NULL or 0. I want to display...
2
by: =?Utf-8?B?SmFtZXMgUGFnZQ==?= | last post by:
I’m trying to create a dynamic asp.net 2.0 siteMapPath control (using VB.net). Using the xml sitemap I’ve got these three pages: productGroup.aspx productListing.aspx productDetail.aspx ...
3
by: pingsheng | last post by:
Dear all, I have a form with dynamically created input fields. These fields go to next page for submitting into SQL database. The thing is all fields are the same but 4 fields. So each record...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.