Define a function and bind to that(assume your datasource is a DataView):
public string GetDynamicValue (object dataItem)
{
DataRowView drv = dataItem As DataRowView;
string fieldValue = "N/A";
string fieldToReturn = "";
if (somecondition)
{
fieldToReturn = "LastName";
}
else
{
fieldToReturn = "FirstName" ;
}
if (drv != null)
{
fieldValue = drv[fieldToReturn].ToString();
}
return fieldValue;
}
then in your script:
<%# GetDynamicValue ( Container.DataI tem ) %>
if you're not sure what type your DataItem is, you can start with this:
public string GetDynamicValue ( object dataItem )
{
return dataItem.ToStri ng();
}
-chris
"Tom Lee" <an*******@disc ussions.microso ft.com> wrote in message
news:05******** *************** *****@phx.gbl.. .
Hi all,
I have the following problem and I cannot solve it. If
anyone can help me solve this problem.
I use the following code
<%#DataBinder.E val(Container.D ataItem, "Property") %>
to display Property from database. How do I dynamically
change the value "Property" to another one say "Name" to
display the Name from database or to any other variable
that I want.
Thanks.