Showing posts with label hyperlink. Show all posts
Showing posts with label hyperlink. Show all posts

Monday, March 26, 2012

Passing values from one page to another

How do I pass values from one page to another without using a button for redirection. That means on my source page I have a hyperlink that redirects to some target page. I have a label on the source page whose text I want to pass to the target page. How can I do that?

Use the querystring.

http://www.codeproject.com/aspnet/QueryString.asp

Passing values between pages

http://www.firoz.name/2006/05/07/passing-values-between-pages/

Wednesday, March 21, 2012

Passing variables in query string in the HyperLinkColumn of a datagrid

Hi All,
I have to pass variable in a query string.
The query string is in the hyperlink coloumn of a datgrid.
The code appears like this
<asp:HyperLinkColumn DataNavigateUrlField="ProductID"
DataNavigateUrlFormatString="ViewProduct.aspx?qProductID='<%strProduct%>'"
DataTextField="ProductID" HeaderText="Product ID">
<HeaderStyle Width="10%"></HeaderStyle>
</asp:HyperLinkColumn>
this does not work..
Can any one help..Where is <%strProduct%>' coming from. Is this a column in your datasource.
If so then you need to sue the binding synthax '<%# strProduct%>'
TDAVISJR
aka - Tampa.NET Koder
<aparnasinha26@.yahoo.com> wrote in message
news:1116325678.716477.36020@.z14g2000cwz.googlegroups.com...
> Hi All,
> I have to pass variable in a query string.
> The query string is in the hyperlink coloumn of a datgrid.
> The code appears like this
> <asp:HyperLinkColumn DataNavigateUrlField="ProductID"
> DataNavigateUrlFormatString="ViewProduct.aspx?qProductID='<%strProduct%>'"
> DataTextField="ProductID" HeaderText="Product ID">
> <HeaderStyle Width="10%"></HeaderStyle>
> </asp:HyperLinkColumn>
>
> this does not work..
> Can any one help..
>
Hi,
Thanks..
To continue with ur question..
No '<%=ADstrProduct%>' is a variable which stores the value from a query
string.
The page is accepting a query string which is stored in query string
'qProduct'
I assign qProduct to the public variable strProduct on form load in my
code behind file of asp.net.
the code behind is VB ie I am working on VB.Net.
I hope this clears your question

Passing variables in query string in the HyperLinkColumn of a datagrid

Hi All,
I have to pass variable in a query string.
The query string is in the hyperlink coloumn of a datgrid.

The code appears like this
<asp:HyperLinkColumn DataNavigateUrlField="ProductID"
DataNavigateUrlFormatString="ViewProduct.aspx?qProductID='<%strProduct%>'"
DataTextField="ProductID" HeaderText="Product ID">
<HeaderStyle Width="10%"></HeaderStyle>
</asp:HyperLinkColumn
this does not work..
Can any one help..Where is <%strProduct%>' coming from. Is this a column in your datasource.
If so then you need to sue the binding synthax '<%# strProduct%>'

--
TDAVISJR
aka - Tampa.NET Koder

<aparnasinha26@.yahoo.com> wrote in message
news:1116325678.716477.36020@.z14g2000cwz.googlegro ups.com...
> Hi All,
> I have to pass variable in a query string.
> The query string is in the hyperlink coloumn of a datgrid.
> The code appears like this
> <asp:HyperLinkColumn DataNavigateUrlField="ProductID"
> DataNavigateUrlFormatString="ViewProduct.aspx?qProductID='<%strProduct%>'"
> DataTextField="ProductID" HeaderText="Product ID">
> <HeaderStyle Width="10%"></HeaderStyle>
> </asp:HyperLinkColumn>
>
> this does not work..
> Can any one help..
Hi,
Thanks..
To continue with ur question..
No '<%*strProduct%>' is a variable which stores the value from a query
string.
The page is accepting a query string which is stored in query string
'qProduct'
I assign qProduct to the public variable strProduct on form load in my
code behind file of asp.net.
the code behind is VB ie I am working on VB.Net.

I hope this clears your question

passing variables to new aspx page using hyperlink column from a datagrid

I am trying to get the value of the hyperlink column to the second aspx page to use it in a sql query. I have it passing to the new page. I don't know how to get/receive it in the new page. Any help would be appreciated.

<Columns>
<asp:TemplateColumn ><ItemTemplate>
<asp:HyperLink runat="Server" NavigateUrl='<%# "../IPDP/ViewObjective.aspx?PlanID=" & DataBinder.Eval(Container.DataItem, "IPDP_PLAN_ID") & "&ObjID=" & DataBinder.Eval(Container.DataItem, "IPDP_OBJ_ID")%>' Text="VIEW" ID="hyperObj"/>
</asp:HyperLink></ItemTemplate></asp:TemplateColumn

example on other page request("PlanID")
Maybe I'm misunderstanding you. This is what I have and the error it's giving me.

From page1:
<asp:TemplateColumn HeaderText="Select Ticket">
<ItemTemplate>
<asp:HyperLink id="HyperLink1" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Number")%>' NavigateUrl='<%# "ticketsearch_db2a.aspx?Number=" & DataBinder.Eval(Container, "DataItem.Number")%>' />
</ItemTemplate>
</asp:TemplateColumn
On page2:

Dim TicNumber as string
TicNumber = request("Number")
Dim vNumber as String
Dim vName as String
Dim vDtissue as String
Dim vrace as String
Dim vsex as String
Dim vDlNum as String
Dim voffcode as String
Dim vspact as String
Dim vsppost as String
Dim vDtCourt as String
Dim vCity as String
Dim vStreet as String
Dim vCitype as String
Dim vCourt as String
Dim strConn as string = "server='sma18'; user id='sdasch'; password='ilovemynewhouse'; database='bluegrass"& _
"'"
Sub DoQuery(Source as Object, E as EventArgs)

Dim MySQL as string = "SELECT [Tickets].* FROM [Tickets] WHERE [Tickets].[number] = '" & TicNumber & "'"
Dim MyConn as New SQLConnection(strConn)
Dim ds as DataSet=New DataSet()
Dim Cmd as New SQLDataAdapter(MySQL,MyConn)
Cmd.Fill(ds,"Tickets")

'These lines assign the data to a variable, which is then assigned to the text property of a literal control(litEmps)
Dim dr As DataRow
For Each dr In ds.Tables("Tickets").Rows
vNumber+=dr("vnumber")
vName+=dr("first") & " " & dr("middle") & " " & dr("last") & " " & dr("suffix")
vDtissue+=dr("dtissue")
vrace+=dr("race")
vsex+=dr("sex")
vDlNum+=dr("dlnum")
voffcode+=dr("offcode")
vspact+=dr("spact")
vsppost+=dr("sppost")
vDtcourt+=dr("dtcourt")
vCity+=dr("city")
vStreet+=dr("street")
vCitype+=dr("citype")
vcourt+=dr("court")
Next
number1.text=vNumber
name1.text=vName
dtissue1.text=vdtissue
race1.text=vrace
sex1.text=vsex
DlNum1.text=vdlnum
offcode1.text=voffcode
spact1.text=vspact
sppost1.text=vsppost
Dtcourt1.text=vdtcourt
Street1.text=vstreet

Error:
Compiler Error Message: BC30188: Declaration expected.

Line 7: Dim TicNumber as string
Line 8: TicNumber = request("Number")
you can try Request.QueryString.Get("Number") for line 8
Thanks for trying. That gives me the same error.

I have <%=Request("Number")%> in the HTML portion of the code and that seems to give me the Number printed on the screen. I just need to figure out how to get it into a variable to use in the sql statement.

If you have any other ideas, I would appreciate them.

Again, Thanks for your help.

Follow this logic...

Function getRequestID()
Dim ID as INTEGER
ID = Request.QueryString("ID")
return ID
END FUNCTION

Where Function is called...
Page.aspx?ID=<%=getRequestID()%>