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> 

Open in new window

Daves166Asked:
Who is Participating?
 
gopaltaydeConnect With a Mentor Commented:
modified the solution provided by cslimrun as below -
GetBranch(Convert.ToString(DataBinder.Eval(Container.DataItem, "BrnId")))

It should work
0
 
cslimrunCommented:
try this:
<td width="786" height="40" align="left" valign="top" class="resultsbold">Location:  <%# GetBranch(DataBinder.Eval(Container.DataItem, "BrnId")) %> </td>

Open in new window

0
 
Daves166Author Commented:
When I do that I get the following error message:
CS1502: The best overloaded method match for 'ASP:Search_New_Trucks_aspx.GetBranch(String)' has some invalid arguments.
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

 
Daves166Author Commented:
I tried the following also:
<% string myBranch; myBranch=databinder.eval(Container.dataitem, "BrnId"); GetBranch(myBranch) %>

Still got an error.
0
 
cslimrunCommented:
<td width="786" height="40" align="left" valign="top" class="resultsbold">Location:  <%# GetBranch(DataBinder.Eval(Container.DataItem, "BrnId").ToString()) %> </td>
0
 
Daves166Author Commented:
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.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.