-----------------------------------------------------------

New Message on BDOTNET

-----------------------------------------------------------
From: RajkumarD
Message 4 in Discussion

Hi,
 There are 2 ways to do it.
        1) Using datareader
        2) Using DataSet or DataTable

1) Using DataReader: But I feel, this solution looks cumbersome.

                        List1.Items.Clear();
                        MobileListItem mi=null;

                        while (reader.Read())
                        {
                                mi = new 
MobileListItem(reader.GetString(0),reader.GetString(1));
                                List1.Items.Add(mi);

                        }
                        List1.ItemsAsLinks = true;


2) Solution: This is better but is not complete.

Create a dataset or datatable using the adapter class, fill it and bind it
to the list box as shown in the example below taken from MSDN.

(You don't have to create the navigation class for your solution.)

Public class Navigation
{
   private String _siteName, siteURL;
   public Navigation(String siteName, String siteURL)
   {
      _siteName = siteName;
      _siteURL = siteURL;
   }
   public String SiteName { get { return _siteName; } }
   public String SiteURL ( get ( return _siteURL; ) )
}

public void Page_Load(Object sender, EventArgs e)
{
   if (!IsPostBack)
   {
      List1.DataTextField="SiteName";
      List1.DataValueField="SiteURL";
      ArrayList arr = new ArrayList();
      arr.Add (new Navigation ("Travel Site",
                               "http://www.margiestravel.com";));
      arr.Add (new Navigation ("Home Site",
                               "http://www.microsoft.com";));
      List1.DataSource = arr;
      List1.ItemsAsLinks = true;
      List1.DataBind ();
   }
}



-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/bdotnet/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you received 
this message by mistake, please click the "Remove" link below. On the pre-addressed 
e-mail message that opens, simply click "Send". Your e-mail address will be deleted 
from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to