Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > DataBinder.Eval for an object's property property... like Eval(Container.DataItem,"Version.Major")

Reply
Thread Tools

DataBinder.Eval for an object's property property... like Eval(Container.DataItem,"Version.Major")

 
 
Eric Newton
Guest
Posts: n/a
 
      04-04-2005
Given databinding an array of System.Version types:

Given that "SomeObject" type has a Version property:

public class SomeObject
{
public Version Version { get; }
public string Description { get; }
}

and I want to bind a list of them to a datagrid.

DataGrid1.DataSource = someObjectList; // basically an array of "someobject"
DataGrid1.DataBind();

How does one utilize the DataBinder.Eval (and in asp.net v2.0, the Eval
method) to get to the SomeObject.Version.Major property?

(Assuming ALL that other stuff is Syntax proper, and so forth)

--
Eric Newton
eric.at.ensoft-software.com
www.ensoft-software.com
C#/ASP.net Solutions developer



 
Reply With Quote
 
 
 
 
Brock Allen
Guest
Posts: n/a
 
      04-04-2005
In your template:

<asp:Repeater ...>
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "Version") %> is the version<br/>
<%# DataBinder.Eval(Container.DataItem, "Description") %> is the description<br/>
</ItemTemplate>
</asp:Repeater>

Container.DataItem is the "row" you're databinding to. The "row" can be any
object, SomeObject in your case. DataBinder.Eval dynamicaly looks up on the
first parameter the propery specified by the secon parameter and returns
the string representation. this is used to fill in the Repeter's rendering.

-Brock
DevelopMentor
http://staff.develop.com/ballen



> Given databinding an array of System.Version types:
>
> Given that "SomeObject" type has a Version property:
>
> public class SomeObject
> {
> public Version Version { get; }
> public string Description { get; }
> }
> and I want to bind a list of them to a datagrid.
>
> DataGrid1.DataSource = someObjectList; // basically an array of
> "someobject" DataGrid1.DataBind();
>
> How does one utilize the DataBinder.Eval (and in asp.net v2.0, the
> Eval method) to get to the SomeObject.Version.Major property?
>
> (Assuming ALL that other stuff is Syntax proper, and so forth)
>




 
Reply With Quote
 
 
 
 
Eric Newton
Guest
Posts: n/a
 
      04-04-2005
I was actually talking about the Version property's Major property...
because the following doesn't work:

<%# DataBinder.Eval(Container.DataItem, "Version.Major") %>

I'm trying to find out if there's a different delimiter (besides the
intuitive ".") to use to tell the Eval method to give me
SomeObject.Version.Major

--
Eric Newton
eric.at.ensoft-software.com
www.ensoft-software.com
C#/ASP.net Solutions developer

"Brock Allen" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ...
> In your template:
>
> <asp:Repeater ...>
> <ItemTemplate>
> <%# DataBinder.Eval(Container.DataItem, "Version") %> is the version<br/>
> <%# DataBinder.Eval(Container.DataItem, "Description") %> is the
> description<br/>
> </ItemTemplate>
> </asp:Repeater>
>
> Container.DataItem is the "row" you're databinding to. The "row" can be
> any object, SomeObject in your case. DataBinder.Eval dynamicaly looks up
> on the first parameter the propery specified by the secon parameter and
> returns the string representation. this is used to fill in the Repeter's
> rendering.
>
> -Brock
> DevelopMentor
> http://staff.develop.com/ballen
>
>
>
>> Given databinding an array of System.Version types:
>>
>> Given that "SomeObject" type has a Version property:
>>
>> public class SomeObject
>> {
>> public Version Version { get; }
>> public string Description { get; }
>> }
>> and I want to bind a list of them to a datagrid.
>>
>> DataGrid1.DataSource = someObjectList; // basically an array of
>> "someobject" DataGrid1.DataBind();
>>
>> How does one utilize the DataBinder.Eval (and in asp.net v2.0, the
>> Eval method) to get to the SomeObject.Version.Major property?
>>
>> (Assuming ALL that other stuff is Syntax proper, and so forth)
>>

>
>
>



 
Reply With Quote
 
Brock Allen
Guest
Posts: n/a
 
      04-04-2005

> I was actually talking about the Version property's Major property...
> because the following doesn't work:
>
> <%# DataBinder.Eval(Container.DataItem, "Version.Major") %>


As long as those are all public properties (fields don't work), then that
syntax should work fine.

-Brock
DevelopMentor
http://staff.develop.com/ballen



 
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
TableCell: BackColor Property But No BackGround Property? Nathan Sokalski ASP .Net 1 04-29-2006 10:09 PM
object-like macro used like function-like macro Patrick Kowalzick C++ 5 03-14-2006 03:30 PM
How to implement a property like ControlToValidate property? Jeff ASP .Net Web Controls 6 05-02-2005 01:49 PM
Set CSS property equal to another CSS property? Noozer HTML 10 10-13-2004 09:20 PM
Is there a way to set the a CSS property to be explicitly the same as another CSS property? Joshua Beall HTML 1 12-10-2003 07:21 PM



Advertisments