Mobile:List & DataBind
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngmob' list.


Igor Hudolin
I bind my Mobile:List with dataset that contains 3 fields A B & C. How can I
display list with text A + " " + B + " " + C.

I know must use OnDataBind event, but I don't know how to get values of the
fields.

Regards, Igor Hudolin

Reply to this message...
 
    
Shanku Niyogi
You're correct, although the actual name of the event is ItemDataBind
(declared as OnItemDataBind on the control tag).=20

When you register an event handler for this event, your event is raised
for every item that gets databound. Your handler is passed an argument
with the type ListDataBindEventArgs, which has two properties. The
first, ListItem, gives you the item in the list that is being databound.
The second, DataItem, gives you the data item to which the item is being
databound.=20

In the case of databinding to a dataset, the DataItem will be a DataRow.
You could cast the DataItem value to a DataRow, and use DataRow
properties to look up the values you need, as follows:

void List_ItemDataBind(Object sender, ListDataBindEventArgs e)
{
DataRow row =3D (DataRow)e.DataItem;
e.ListItem.Text =3D String.Format("{0} {1} {2}", row["A"], row["B"],
row["C"]);
}

Shanku

--
This posting is provided "AS IS" with no warranties, and confers no
rights.=20

-----Original Message-----
From: Igor Hudolin [mailto:Click here to reveal e-mail address]=20
Sent: Thursday, April 04, 2002 4:47 AM
To: aspngmob
Subject: [aspngmob] Mobile:List & DataBind

I bind my Mobile:List with dataset that contains 3 fields A B & C. How
can I display list with text A + " " + B + " " + C.

I know must use OnDataBind event, but I don't know how to get values of
the fields.

Regards, Igor Hudolin

| [aspngmob] member Click here to reveal e-mail address =3D YOUR ID=20
| http://www.asplists.com/asplists/aspngmob.asp =3D JOIN/QUIT=20
| http://www.asplists.com/search =3D SEARCH Archives

Reply to this message...
 
    
Simon Calvert
A few ways:

- Declaratively create a ItemTemplate and within create the following
    DataBinder.Eval(((ListItem)Container).DataItem, "A") "Text"
DataBinder.Eval(((ListItem)Container).DataItem, "B") "Text"
DataBinder.Eval(((ListItem)Container).DataItem, "B") "Text"<br>

- Programmatically. Handle the OnItemDataBind event and add a format
string to assign the text of the list item
    e.ListItem.Text =3D String.Format("{0} text {1} text {2}",
                    DataBinder.Eval(e.DataItem,
"A"),
                    DataBinder.Eval(e.DataItem,
"B"),
                    DataBinder.Eval(e.DataItem, "C")
);

And just before I post this I see Shanku gave more details on #2.

Hope this helps
Simon Calvert
This posting is provided "AS IS" with no warranties, and confers no
rights.

-----Original Message-----
From: Igor Hudolin [mailto:Click here to reveal e-mail address]=20
Sent: Thursday, April 04, 2002 4:47 AM
To: aspngmob
Subject: [aspngmob] Mobile:List & DataBind

I bind my Mobile:List with dataset that contains 3 fields A B & C. How
can I
display list with text A + " " + B + " " + C.

I know must use OnDataBind event, but I don't know how to get values of
the
fields.

Regards, Igor Hudolin

| [aspngmob] member Click here to reveal e-mail address =3D YOUR ID
| http://www.asplists.com/asplists/aspngmob.asp =3D JOIN/QUIT
| http://www.asplists.com/search =3D SEARCH Archives

Reply to this message...
 
 
System.Data.DataRow
System.String
System.Web.UI.DataBinder
System.Web.UI.MobileControls.ListDataBindEventArgs
System.Web.UI.WebControls.ListItem




Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
 
 Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us - Terms of Use - Privacy Policy - www.dotnet247.com