pass more than one parm

G

Guest

hey all,
i'm in a template column of a gridview. i have a hyperlink in the Item
Template and i'm trying to do a custom binding expression to it. So far i
have the following:

Eval("FILE_ID", "~/ViewFile.aspx?Id={0}")

Is there a way to pass more than one parm? If so, could someone please show
me the syntax?

thanks,
rodchar
 
G

Guest

rodchar said:
hey all,
i'm in a template column of a gridview. i have a hyperlink in the Item
Template and i'm trying to do a custom binding expression to it. So far i
have the following:

Eval("FILE_ID", "~/ViewFile.aspx?Id={0}")

Is there a way to pass more than one parm? If so, could someone please show
me the syntax?

thanks,
rodchar

rod,

Inside your binding syntax, you'll have to call another formating function
that takes multiple arguments. Try this:

<ItemTemplate>
<asp:HyperLink ID="lnkTest" runat="server"
NavigateUrl='<%# String.Format("~/Temp.aspx?id={0}&id2={1}", Eval("id1"),
Eval("id2")) %>' Text="Link 1"></asp:HyperLink>
</ItemTemplate>

If your binding is more complicated than what string.Format() can handle
then declare a function in your codebehind and call that function inside your
templated column. Something like:

inside your codebehind declare a function...

public string FormatURL(string arg1, string arg2)
{
return string.Format("~/Temp.aspx?id={0}&id1={1}", arg1, arg2);
}


<ItemTemplate>
<asp:HyperLink ID="lnkAnotherTest" runat="server"
NavigateUrl='<%# FormatURL(Eval("id1").ToString(), Eval("id2")).ToString()
%>' Text="Link 2">
</asp:HyperLink>
</ItemTemplate>

Hope this helps,
Jason Vermillion
 
G

Guest

awesome, thank you for the help. rod.

Jason Vermillion said:
rod,

Inside your binding syntax, you'll have to call another formating function
that takes multiple arguments. Try this:

<ItemTemplate>
<asp:HyperLink ID="lnkTest" runat="server"
NavigateUrl='<%# String.Format("~/Temp.aspx?id={0}&id2={1}", Eval("id1"),
Eval("id2")) %>' Text="Link 1"></asp:HyperLink>
</ItemTemplate>

If your binding is more complicated than what string.Format() can handle
then declare a function in your codebehind and call that function inside your
templated column. Something like:

inside your codebehind declare a function...

public string FormatURL(string arg1, string arg2)
{
return string.Format("~/Temp.aspx?id={0}&id1={1}", arg1, arg2);
}


<ItemTemplate>
<asp:HyperLink ID="lnkAnotherTest" runat="server"
NavigateUrl='<%# FormatURL(Eval("id1").ToString(), Eval("id2")).ToString()
%>' Text="Link 2">
</asp:HyperLink>
</ItemTemplate>

Hope this helps,
Jason Vermillion
 

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,996
Messages
2,570,237
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top