.NETGURU
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




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification