Click to See Complete Forum and Search --> : hyperlink with querystring?


eeccll
03-23-2006, 10:23 AM
I know this is easy.. but i just could not solve this..
How to write querystring by using webforms hyperlink?
So that it will look similar to the hyperlink that we use in datagrid (the URL field and URL format string).
Many thanks.. ^.^

sirpelidor
03-23-2006, 04:15 PM
suppose ur hyperlink is named lnkMylink

in ur code behind:

lnkMylink.NavigateUrl = "(url).(extension)?(queryname)=(value)";

i.e:
mypage2.aspx?myvalue=blahblahblah

eeccll
03-24-2006, 01:59 PM
So is it we have to set the (value) to some actual values, like "mypage2.aspx?username=eeccll"? Or can we do the same like in datagrid hyperlink, that we can specify the URL field, so it will redirect to other page base on the currect username..

sirpelidor
03-24-2006, 02:20 PM
yes, a hyperlink control within your datagrid is just like a hyperlink control in a webform (well... with some very minor diff which you shouldn't have to deal with it at this point)

However, if you just want to put a html link inside your grid, you don't need to complicated yourself by using webcontrol, the following is one of the solution off the top of my head:

suppose you load a datagrid off a DataSet (from a sql table including your user ID # call "ID")

somewhere in your grid, u wanna show a hyperlink:

<ItemTemplate>
<a href='mypage2.aspx?ID=<%# DataBinder.Eval(Container.DataItem, "ID") %>' >Click to see this user</a>
</ItemTemplate>


that way... there will be a text name "Click to see this user" in every rows of your column. When you click it, the correct ID # will forward to the new page, and you can use querystring to retrieve its ID on the new page and run through SQL to get the information that you need.

hope that helps

eeccll
03-24-2006, 10:32 PM
Thanks.. The hyperlink problem is done. How if i wanna update the hits value everytime the user click on the hyperlink? When the new page is closed, how to make the parent page automatic refresh with the new hits value, rather than i have to click the "Refresh" button at the Standard Buttons??

sirpelidor
03-25-2006, 01:46 AM
Thanks.. The hyperlink problem is done. How if i wanna update the hits value everytime the user click on the hyperlink?

You better start a new thread for a diff problem.

eeccll
03-26-2006, 05:49 AM
oopss..sorry..

sajjad27s
03-29-2006, 01:59 AM
Its better to put every code in CODE file .vb or .cs

VS goes mad in code like this (in aspx files)

<a href='mypage2.aspx?ID=<%# DataBinder.Eval(Container.DataItem, "ID") %>' >Click to see this


It will not show the page in design view.