HyperlinkColumn in Datagrid

How do I pass more than one column in query string when used in a datagrid hyperlinkcolumn ?

xxx.aspx?column1={0}&column2= ?
DavidTanisAsked:
Who is Participating?
 
ayha1999Connect With a Mentor Commented:
Try this;

<asp:HyperLink id=HyperLink1 runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "cnt") %>'  NavigateUrl='<%# String.Format(xxx.aspx?a={0}&b={1}",DataBinder.Eval(Container.DataItem, "a"),DataBinder.Eval(Container.DataItem, "b"))%>'>

Hope this works.

ayha
0
 
raterusCommented:
I personally avoid the HyperlinkColumn in favor of a templatecolumn, you have much more control over the final product...Just use <%# .. %> wherever you need the additional information in the url.

                        <asp:templatecolumn>
                              <itemtemplate>
                                    <a href='Summary.aspx?column1=<%# DataBinder.Eval(Container.DataItem, "column1") %>'>View Something <%# DataBinder.Eval(Container.DataItem, "whatever") %></a>
                              </itemtemplate>
                        </asp:templatecolumn>
0
 
HavaganCommented:
And I on the other hand use a TemplateColumn with a Hyperlink control. =)

<asp:templatecolumn>
<itemtemplate>
<asp:hyperlink NavigateUrl='xxx.aspx?column1=<%# DataBinder.Eval(Container.DataItem, "column1") %>&column2=<%# DataBinder.Eval(Container.DataItem, "column2") %>' Text='<%# DataBinder.Eval(Container.DataItem, "columntodisplay") %>'></asp:hyperlink>
</itemtemplate>
</asp:templatecolumn>

Paul
0
 
ayha1999Commented:
hi,

try this:

<asp:HyperLink ID="VariableName" Runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"YourFieldToDisplay") %>' NavigateUrl='<%# String.Format("YourPage.aspx?FieldName1toPass={0}&FieldName2toPass={1}&FieldName3toPass={2}&FieldName4toPass={3}",DataBinder.Eval(Container.DataItem, "FieldNo1"),DataBinder.Eval(Container.DataItem, "FieldNo2"),DataBinder.Eval(Container.DataItem, "FieldNo4"),DataBinder.Eval(Container.DataItem, "FieldNo5"))%>'</asp:HyperLink>

Hope this helps.

ayha
0
 
DavidTanisAuthor Commented:
<asp:TemplateColumn SortExpression="Count" HeaderText="Count">
<ItemTemplate>
<asp:HyperLink id=HyperLink1 runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "cnt") %>' NavigateUrl='xxx.aspx?a=<%# DataBinder.Eval(Container.DataItem, "a") %>&b=<%# DataBinder.Eval(Container.DataItem, "b") %>'>
</asp:HyperLink>
</ItemTemplate>
</asp:TemplateColumn>

When I looked into the querystring, the value for "a" was retrived as "<%" , not the value in column a. and "b" shows nothing.

Is it missing anything in the code? Thanks

0
All Courses

From novice to tech pro — start learning today.