Link to home
Start Free TrialLog in
Avatar of DavidTanis
DavidTanis

asked on

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= ?
Avatar of raterus
raterus
Flag of United States of America image

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>
Avatar of Havagan
Havagan

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
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
Avatar of DavidTanis

ASKER

<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

ASKER CERTIFIED SOLUTION
Avatar of ayha1999
ayha1999

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial