Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Apr 26th, 2006, 4:10 AM   #1
Mitsuki
Newbie
 
Mitsuki's Avatar
 
Join Date: Apr 2006
Posts: 8
Rep Power: 0 Mitsuki is on a distinguished road
listbox + retreiving

hello

I have 2 listbox one of the listboxs retreives its items from an Access DB
and when it is moves to the other listbox it gets saves in another tbl ..

Also when the user presses on the item he should retreive all the info about it but cannot change anything ...


I am trying to do it
this is what i did so far ...

 OleDbConnection conn;
     OleDbCommand cmd;
     OleDbDataAdapter da;
    
    
        System.Data.IDataReader BFTbl() {
            string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data Source=C:\\Inetpub\\HASE" +
                "M\\HASEM.mdb";
            System.Data.IDbConnection dbConnection = new System.Data.OleDb.OleDbConnection(connectionString);
    
            string queryString = "SELECT [tblNewItems].[strName], [tblNewItems].[Date], [tblNewItems].[AWB] FROM [t" +
                "blNewItems]";
            System.Data.IDbCommand dbCommand = new System.Data.OleDb.OleDbCommand();
            dbCommand.CommandText = queryString;
            dbCommand.Connection = dbConnection;
    
            dbConnection.Open();
            System.Data.IDataReader dataReader = dbCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection);
    
            return dataReader;
        }
     private void Button1_Click(object sender, System.EventArgs e)
     {
     string strSelection;
     if (ListBox1.SelectedItem != null)
     {
     strSelection = ListBox1.SelectedItem.Text;
     if (ListBox2.Items.FindByText(strSelection)== null )
     {
     ListBox2.Items.Add(strSelection);
     ListBox2.SelectedIndex =0;
     ListBox1.Items.Remove(strSelection);
     }
     }
     }
    
     private void Button2_Click(object sender, System.EventArgs e)
     {
     string strSelection;
    if (ListBox2.SelectedItem != null)
         {
         strSelection = ListBox2.SelectedItem.Text;
         if (ListBox1.Items.FindByText(strSelection)== null )
         {
         ListBox1.Items.Add(strSelection);
         ListBox1.SelectedIndex =0;
         ListBox2.Items.Remove(strSelection);
         }
         }
         }
    
         private void Page_Load(object sender, System.EventArgs e)
         {
         if (!IsPostBack)
         {
        //Put user code to initialize the page here
         conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Inetpub\\HASEM\\HASEM.mdb;");
         cmd = new OleDbCommand("select strName from tblNewItems",conn);
         da= new OleDbDataAdapter(cmd);
    
         Dim dsColor = new DataSet();
         da.Fill(dsColor);
    
         ListBox1.DataSource = dsColor;
         ListBox1.DataTextField = "strName";
         ListBox1.DataBind();
         ListBox1.SelectedIndex = 0;
         }
         }

</script>

Please I need your help I have like 10 more pages to validate in 2 weeks and it is a very short time :cry2:
Mitsuki is offline   Reply With Quote
Old Apr 29th, 2006, 2:13 PM   #2
melbolt
Professional Programmer
 
melbolt's Avatar
 
Join Date: Feb 2005
Location: PA, USA
Posts: 253
Rep Power: 4 melbolt is on a distinguished road
could you please state the problems you are having with your code? what don't you know how to do? you said what you were trying to do but didn't say what you were having trouble with.
__________________
I have never let my schooling interfere with my education. -Mark Twain-

Xbox live gamertag: melbolt
melbolt is offline   Reply With Quote
Old May 8th, 2006, 3:37 AM   #3
Mitsuki
Newbie
 
Mitsuki's Avatar
 
Join Date: Apr 2006
Posts: 8
Rep Power: 0 Mitsuki is on a distinguished road
I don't know how to do this

when the user presses on an item in listbox the details about the item should be retreived
Mitsuki is offline   Reply With Quote
Old May 8th, 2006, 9:32 PM   #4
melbolt
Professional Programmer
 
melbolt's Avatar
 
Join Date: Feb 2005
Location: PA, USA
Posts: 253
Rep Power: 4 melbolt is on a distinguished road
if i were you i would probably store an object in each list item's tag property. This object will contain all of the data you need to populate the other box with the details of that particular item.

if you don't understand what i mean, let me know and i'll try to explain it better.

when you do your initial query to populate the listbox items, get all of the other data as well and stick it in an object and store it in the tag.

that's how i do stuff like this.
__________________
I have never let my schooling interfere with my education. -Mark Twain-

Xbox live gamertag: melbolt
melbolt is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 6:54 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC