how to pass a complicated string through url querystring

I dynamically added a Hyperlinkcolumn to a  arraylist and the array list will be added to datagrid.:

                        tempHyperLink1 = new HyperLinkColumn();
                        tempHyperLink1.DataTextField = infoTemp.DisplayName;
                        tempHyperLink1.DataTextFormatString = "<img alt=\"Update something\" style=\"border:0\"  src=\"../Images/update.jpg\" />";
                        tempHyperLink1.DataNavigateUrlField = infoTemp.DisplayName;
                        tempHyperLink1.DataNavigateUrlFormatString = "~/anotherFolder/NextPage.aspx?s={0}";
                        tempHyperLink1.HeaderText = "something";
                        alColumns.Add(tempHyperLink1);

But the problem is that {0} is composed of very complicated string and make the url invalid.How to deal with it? I want ot use {0} in the next page. There is no way to create a session variable since it's dynamic. Appreciated for your idea!!!!
jssong2000Asked:
Who is Participating?
 
MlandaTConnect With a Mentor Commented:
An even better approach would be to perhaps find another key value to use in the querystring, say an integer, but one that would still allow you to retrieve the required string value on NextPage.aspx.
0
 
jssong2000Author Commented:
urlencode make the string too long.....
0
 
jssong2000Author Commented:
Actually it's no way to make a url encode since it's dynamic. So you can't make it like:

tempHyperLink1.DataNavigateUrlFormatString = "~/anotherFolder/NextPage.aspx?s=" + Server.UrlEncode("{0}");
It will encode these symbols {0}
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
MlandaTCommented:
You could change the Hyperlinkcolumn into a templatecolumn, add a hyperlink, and then find the Hyperlink in the databound method, then format the string and assign it a value there...
Public Sub myGrid_Bound(sender As Object, e As DataGridItemEventArgs) Handles myGrid.ItemDataBound

    if e.Item.ItemType = ListItemType.Item or e.Item.ItemType = ListItemType.AlternatingItem then

        Dim myHyperlinkAs Hyperlink = CType(e.item.cells(1).FindControl("myHyperlink"), Hyperlink )
        if myHyperlink isnot nothing then myHyperlink.NavigateUrl = "~/anotherFolder/NextPage.aspx?s=" & Server.UrlEncode("{0}")

    end if

end sub

Open in new window

0
 
dexion432Commented:
request length can be 2k, post length can be 8k.

change request length in the iis config or send the url in post, not in the url.
0
 
jssong2000Author Commented:
MlandaT - I tried to add another key in the table. But the table will be updated everyweek. So the id may be different in two tables as usually PK and FK relationship.

dexion432- Could you please explain a little detail? Thanks!!!!

My page's content is:
<%@ Register Src="~/Controls/QuerySpecification.ascx" TagName="SearchSpecification" TagPrefix="Custom" %>
<%@ Register Src="~/Controls/SearchResultsGrid.ascx" TagName="SearchResults" TagPrefix="Grid" %>
<asp:Content ContentPlaceHolderID="head" ID="headerInfo" runat="server">
</asp:Content>
<asp:Content ContentPlaceHolderID="bodyContent" ID="cBody" runat="server">
  <Custom:SearchSpecification ID="cntrlSearchSpecs" runat="server"></Custom:SearchSpecification>
     <Grid:SearchResults ID="cntrlSearchResults" DisplayNumber="50" runat="server" Visible="false">
    </Grid:SearchResults>
</asp:Content>

datagrid is in cntrlSearchResults
0
 
jssong2000Author Commented:
MlandaT:

what is c# for your
 Dim myHyperlinkAs Hyperlink = CType(e.item.cells(1).FindControl("myHyperlink"), Hyperlink )? Thanks!!!
0
 
jssong2000Author Commented:
This is helpful. Thanks!!!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.