Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 passing parameters in a hyperlink

Author  Topic 

JJ297
Aged Yak Warrior

940 Posts

Posted - 2009-05-20 : 14:39:32
I am trying to pass four parameters with a hyperlink in a Gridview

I set this up in a template field and it goes to the next page but nothing appears, I have a gridview on the other page (area.aspx)

Here's the code what am I doing wrong?

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" Width="379px" AllowSorting="True">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:HyperLink ID="HyperLink1" runat="server"

NavigateUrl='<%# Eval("Area", "Area.aspx?Area={0}&period="&Request.QueryString("period") &" BgnDt=" & Request.QueryString(1) &" EndDt=" & Request.QueryString(2)) %>'

Text='<%#Eval("Area", "{0}")%>'></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="totc" HeaderText="Diaries Cleared" ReadOnly="True" SortExpression="totc" />
<asp:BoundField DataField="totm" HeaderText="Cleared W/I 90 Days" ReadOnly="True" SortExpression="totm" />
<asp:BoundField DataField="perc" HeaderText="Percent W/I 90 Days" ReadOnly="True" SortExpression="perc" />
</Columns>
</asp:GridView>

I get this in the url:
http://localhost:49646/Area.aspx?Area=03&period=w%20BgnDt=05/15/2009%20EndDt=05/15/2009

I was wondering if the %20 in front of BgnDt and EndDt is stopping my page from loading.

Here's the area.aspx.vb page:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim Area as String = Request.Querystring("Area")
Dim Period As String = Request.QueryString("Period")
Dim bgndt As String = Request.QueryString("bgndt")
Dim EndDt As String = Request.QueryString("EndDt")

End Sub

JJ297
Aged Yak Warrior

940 Posts

Posted - 2009-05-21 : 12:05:45
Added this to the code behind but still not working:

Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound

Dim txt As String = e.Row.Cells(0).Text 'get the current text
If e.Row.RowType = DataControlRowType.DataRow Then
If e.Row.Cells(0).Text = "Area" Then
Dim hl As HyperLink = TryCast(e.Row.FindControl("HyperLink1"), HyperLink)

If txt = "01" Or txt = "02" Or txt = "03" Or txt = "04" Or txt = "05" Or txt = "06" Or txt = "07" Or txt = "08" Or txt = "09" Then

hl.NavigateUrl = "area.aspx?area=" & Request.QueryString("area") & "&" & "period" & "=" & Request.QueryString("bgndt") & "&" & "Enddt" & "=" & Request.QueryString("Enddt")
End If
End If
End If
End Sub

Any ideas?
Go to Top of Page
   

- Advertisement -