Thursday, March 29, 2012

pass more than one parm

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"rodchar" wrote:

Quote:

Originally Posted by

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
awesome, thank you for the help. rod.

"Jason Vermillion" wrote:

Quote:

Originally Posted by

"rodchar" wrote:

Quote:

Originally Posted by

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
>
>

0 comments:

Post a Comment