how to send two parameters in HyperLinkColumn?

S

sincethe2003

Hi, in the following example:
-----------
<asp:HyperLinkColum
HeaderText="Select an Item"
DataNavigateUrlField="IntegerValue"
DataNavigateUrlFormatString="detailspage.aspx?id={0}"
DataTextField="PriceValue"
DataTextFormatString="{0:c}"
Target="_blank"/>
 
S

Scott Allen

Hi sincethe2003:

You could add script to actually perform the String.Format in ASPX:

DataNavigateUrlFormatString=
<%= String.Format("detailspage.aspx?id={0}", id); %>
 
S

sincethe2003

how to send the second parameter?
for example:
<%= String.Format("detailspage.aspx?id={0}&name={1}", id, name);
but this is not work....

Scott Allen said:
Hi sincethe2003:

You could add script to actually perform the String.Format in ASPX:

DataNavigateUrlFormatString=
<%= String.Format("detailspage.aspx?id={0}", id); %>
 
S

sincethe2003

yes, it will cause error,
because it seems only {0} is accepted, the second parameter using {1} will
cause error .....
 
J

Joe Fallon

This is a known limitation of the hyperlink column.
It will only take 1 parameter.

Try using a template column instead:
============================================================
<asp:TemplateColumn SortExpression="mynumber" HeaderText="My Number">
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
<ItemTemplate>
<asp:Hyperlink id="hylMyNumber" runat="server"></asp:Hyperlink>
</ItemTemplate>
</asp:TemplateColumn>
============================================================

Then in code behind you can use: (mColl is custom collection object.)
============================================================

Private Sub dg1_ItemDataBound(ByVal sender As Object, ByVal e As
DataGridItemEventArgs) Handles dg1.ItemDataBound

If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType =
ListItemType.AlternatingItem Then

'need to take paging into account.
Dim mIndex As Integer = CType(sender, DataGrid).PageSize *
CType(sender, DataGrid).CurrentPageIndex + e.Item.ItemIndex

Dim obj As HyperLink = CType(e.Item.FindControl("hylMyNumber"),
HyperLink)
obj .NavigateUrl = "javascript:LeftSideWin('ViewNum.aspx?Key=" &
mColl(mIndex).key & "&KeyType=" & mColl(mIndex).type & "','MyWin');"
obj .Text = mColl.(mIndex).mynumber

End If

End Sub
============================================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top