Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Passing value into DataBinder.Eval(Container.DataItem, "Property")

Reply
Thread Tools

Passing value into DataBinder.Eval(Container.DataItem, "Property")

 
 
Tom Lee
Guest
Posts: n/a
 
      12-08-2003
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.Eval(Container.DataItem, "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.
 
Reply With Quote
 
 
 
 
lostinet
Guest
Posts: n/a
 
      12-09-2003
<%#DataBinder.Eval(Container.DataItem,
DataBinder.Eval(Container.DataItem,"PropertyName", "{0}")
)%>

"Tom Lee" <(E-Mail Removed)> ????
news:054c01c3bdd9$cc2956c0$(E-Mail Removed)...
> 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.Eval(Container.DataItem, "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.



 
Reply With Quote
 
 
 
 
Chris Carter
Guest
Posts: n/a
 
      12-09-2003
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.DataItem ) %>

if you're not sure what type your DataItem is, you can start with this:

public string GetDynamicValue ( object dataItem )
{
return dataItem.ToString();
}

-chris
"Tom Lee" <(E-Mail Removed)> wrote in message
news:054c01c3bdd9$cc2956c0$(E-Mail Removed)...
> 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.Eval(Container.DataItem, "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.



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to compare value of two fileds and based on that insert value into third fileds Tradeorganizer ASP General 5 01-31-2007 04:51 AM
problem in passing a value into a structure iskeletor C Programming 3 12-15-2006 02:13 AM
Getting value from asp:label into javascript input value Dwizz Javascript 10 08-07-2005 02:28 AM
Passing Value from session into a usercontrol Microsoft ASP .Net Web Controls 0 04-03-2005 01:31 AM
Passing by const & and returning a temp vs passing by value and returningit Victor Bazarov C++ 25 03-23-2005 04:24 PM



Advertisments