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

New Message on cochindotnet

-----------------------------------------------------------
From: mathewphilipp
Message 5 in Discussion

Dear all, it was a problem with listbox , previously i was added the listbox 
item with a loop.then it was taken around 40 minutes to populate. Now i am 
using a new code with datatable so it takes only 10 seconds..!!!As a windows 
application i didnt found any databind() metheod, text and value properties for 
litbox etc,but i was solved the issue with the following code.   SqlConnection 
m_con = new SqlConnection("MyConnectionString"); string m_sql = "select id,name 
from tableName order by name";  SqlCommand m_cmd = new SqlCommand(m_sql,m_con); 
SqlDataAdapter m_da = new SqlDataAdapter(m_cmd); DataTable m_dt = new 
DataTable(); m_da.Fill(m_dt); 
lb_Items.DataSource = m_dt; // lb_items is the listbox to populate 
lb_Items.DisplayMember = m_dt.Columns[1].ToString(); lb_Items.ValueMember = 
m_dt.Columns[0].ToString(); lb_Items.EndUpdate();  
To take the selected itesms from the listbox : 
private void lb_Items_SelectedValueChanged(object sender, System.EventArgs e)
  {
   foreach(DataRowView m_MyView in lb_Items.SelectedItems)
   {
    txt_id.Text = m_MyView.Row[0].ToString();
    txt_text.Text = m_MyView.Row[1].ToString();
   } //HERE YOU CAN ASSIGN THE ITEMS TO AN ARRAYLIST , IF YOU HAVE MULTIPLE 
SELECTED ITEMS. " txt_id " and "txt_name" are textboxes   }   THANK YOU FOR ALL

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

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/cochindotnet/_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