?
Solved

databinder.eval question

Posted on 2011-10-14
6
Medium Priority
?
239 Views
Last Modified: 2012-05-12
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

0
Comment
Question by:Daves166
  • 3
  • 2
6 Comments
 
LVL 2

Expert Comment

by:cslimrun
ID: 36970678
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
 

Author Comment

by:Daves166
ID: 36970713
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
 

Author Comment

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

Still got an error.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Expert Comment

by:cslimrun
ID: 36970842
<td width="786" height="40" align="left" valign="top" class="resultsbold">Location:  <%# GetBranch(DataBinder.Eval(Container.DataItem, "BrnId").ToString()) %> </td>
0
 

Author Comment

by:Daves166
ID: 36971093
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
 
LVL 7

Accepted Solution

by:
gopaltayde earned 500 total points
ID: 36973117
modified the solution provided by cslimrun as below -
GetBranch(Convert.ToString(DataBinder.Eval(Container.DataItem, "BrnId")))

It should work
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question