Click here to Skip to main content
15,072,422 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have Binder function like this

<asp:label id="lbl" text="<%#DataBinder.Eval(Container.DataItem, " runat="server" xmlns:asp="#unknown">;

I have one method in code behind like this

public string GetName(string id)
{
if(id == "1")
return "One";
else
return "Something else";
}

Depending on the id in Eval method I want to bind the corresponding string values from the method GetName().

How can I call the method GetName(), which accepts "Id" as parameter, inside the Label ?
Posted
Updated 25-Jun-10 20:46pm
v2

1 solution

Try this.

<asp:Label id="lblTest" runat="server" Text='<%#GetName(Eval("Id").ToString()) %>'>/xml>
   
v4
Comments
Raghavendra HG 26-Jun-10 5:04am
   
Oh man.. It worked.. thanks a lot.. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900