Daves166
asked on
databinder.eval question
I need to evaluate a field then send that data to a function to evaluate once more so I can display a name. Here is what happens, I run a databinder.eval(Container. Dataitem, "BrnId") to get the branch ( it should yield 001, 002 005, etc). Then I want to call my function GetBranch which uses a switch statement to give me the branch name. However, I don't know how to position my inline ASP.Net tags so that it evaluates first, then calls my function second. attached is my code.
<Script Runat="Server" type="text/C#">
public string GetBranch(string BranchId)
{
string Branch = "";
switch(BranchId)
{
case "001":
Branch = "Columbus";
break;
case "002":
Branch = "Youngstown";
break;
case "005":
Branch = "Pittsburgh";
break;
case "006":
Branch = "Barkeyville";
break;
case "007":
Branch = "Cincinnati";
break;
Default:
Branch = "Columbus";
break;
}
return Branch;
}
</Script>
...........
<ItemTemplate>
<table width="946" border="0" cellspacing="0" cellpadding="0" bgcolor="FFFFFF">
<tr>
<td width="160" height="40" align="left" valign="top" class="resultsbold">Unit: <%# DataBinder.Eval(Container.DataItem, "UntId") %></td>
<td width="786" height="40" align="left" valign="top" class="resultsbold">Location: <%# DataBinder.Eval(Container.DataItem, "BrnId") %> </td>
</tr>
ASKER
When I do that I get the following error message:
CS1502: The best overloaded method match for 'ASP:Search_New_Trucks_asp x.GetBranc h(String)' has some invalid arguments.
CS1502: The best overloaded method match for 'ASP:Search_New_Trucks_asp
ASKER
I tried the following also:
<% string myBranch; myBranch=databinder.eval(C ontainer.d ataitem, "BrnId"); GetBranch(myBranch) %>
Still got an error.
<% string myBranch; myBranch=databinder.eval(C
Still got an error.
<td width="786" height="40" align="left" valign="top" class="resultsbold">Locati on: <%# GetBranch(DataBinder.Eval( Container. DataItem, "BrnId").ToString()) %> </td>
ASKER
Same Error as above. It doesn't seem like it's excuting "databinder.eval" first then calling my function. I need it to evaluate the (DataBinder.Eval(Container .DataItem, "BrnId") first then let me call my function.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window