Saturday, March 31, 2012

Setting Local Variable to Dataset Item

Is there a way to have a variable set to an item in a dataset in ASP.net?

For example <% MyValue = <%# rcd_SumsInOrder.FieldValue("TotalOrder", Container) %> %>?

I cannot get it to work for the life of me

Any clarification would be great

ThanksYes, assign it from code behind.

Or, if you are just displaying the variable, databind it to a label/literal control.
Yes.
In the code behind file create something like this:


public function GetSums(strInput as double) as string
return "this is a string result"
end function

If your aspx (example):


<asp:label runat=server text='<%# GetSums(rcd_SumsInOrder.FieldValue("TotalOrder", Container)) %>'>

Just make sure that:
1) You make the function public
2) You return the same datatype as the datatype of the given tag. Ie: for visible return boolean, for text return string.

Regards,
Teddy

0 comments:

Post a Comment