Click here to Skip to main content
       

C#

 
QuestionConnection between two forms in a project Pinmembercoolvibhu16-Mar-13 7:18 
AnswerRe: Connection between two forms in a project PinmemberThePhantomUpvoter16-Mar-13 7:36 
AnswerRe: Connection between two forms in a project PinmvpOriginalGriff16-Mar-13 7:40 
QuestionListBox datasource is not updated on first click Pinmemberzulfakar16-Mar-13 4:24 
i create a winform program that load the data from ms access database to my listbox. when i click my item which i want to update on database and datasource on my listbox and click the update button, the item just wont update for the first time clicked but the second does, so everytime i need to modify my data i need to choose my item and click the update button two times. that's is crazy lol..
 
private void buttonUpdate_Click(object sender, EventArgs e)
    {
        //update the database
        OleDbDataAdapter cmd = new OleDbDataAdapter();
        cmd.UpdateCommand = new OleDbCommand("UPDATE Item SET ITEM = @ITEM, ITEM_DESC = @ITEM_DESC WHERE ID = @ID",GetConnection());
        cmd.UpdateCommand.Parameters.AddWithValue("@ITEM", textBoxITEM.Text);
        cmd.UpdateCommand.Parameters.AddWithValue("@ITEM_DESC", textBoxITEMDESC.Text);
        cmd.UpdateCommand.Parameters.AddWithValue("@ID", Convert.ToInt32(textBoxID.Text));
        cmd.UpdateCommand.ExecuteNonQuery();
 
        // update the datasource
        _productlist.Clear();
        listBox1.DataSource = null;
        listBox1.Items.Clear();
        Fill();
        listBox1.Update();
    }
 
basic thing that happen:
 
1. load data to listbox with databind to textbox
2. click item on my listbox and modify data from textbox
3. click the update button to update database and datasource
4. datasource not update for the first time but database does update
5. repeat no.2
6. repeat no.3
7. datasource updated
 
what i want:
 
1. load data to listbox with databind to textbox
2. click item on my listbox and modify data from textbox
3. click the update button to update database and datasource
4. datasource and database updated
 
how do i fix this bug on my application?? please let me know if i need to be more clear..
AnswerRe: ListBox datasource is not updated on first click PinmemberJegan Thiyagesan16-Mar-13 14:31 
GeneralRe: ListBox datasource is not updated on first click Pinmemberzulfakar17-Mar-13 9:24 
GeneralRe: ListBox datasource is not updated on first click [modified] PinmemberJegan Thiyagesan18-Mar-13 4:50 
QuestionExporting Gridview with fixed number of rows on each page PinmemberAlexRusso16-Mar-13 2:18 
AnswerRe: Exporting Gridview with fixed number of rows on each page PinmvpEddy Vluggen16-Mar-13 13:06 
GeneralRe: Exporting Gridview with fixed number of rows on each page PinmemberAlexRusso18-Mar-13 1:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web03 | 2.8.141223.1 | Last Updated 27 Dec 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid