none
Binding problem RRS feed

  • Question

  • I made the entitys from my database and after generated the object.

    Set the datasource type to DataGridView and dropped to the form and write this code to my form:

     

            myEntities ve = new myEntities();
    
            public Form2()
            {
                InitializeComponent();
    
                itemGridControl.DataSource = ve.items;
            }
    

     

    When I tested the application the datas showed in the grid.

    A wanted to edit the record in a texbox therefore I set datasource type todetail and also dropped the object to the form.

    Displays all of the gridview but the texbox is empty and the cisual stuudio made the databinding as well.

    What do I wrong?

    Thursday, January 5, 2012 2:57 PM

Answers

  • Hi Akoss,

    Welcome to MSDN Forum.

    I'm not clear about the issue. Do you mean you have bind the datasource to your gridview, and you want to edit the record in your gridview. When you turn to Edit mode, the textboxs don't display the values of the record? If I understand correctly, did you store the record's primary key in your gridveiw? If there's a primary key, when you want to modify a record, just query out the recorde from the database through primary key, and assign the record's propery value to the textbox's Text property. After modifying, update the databae through the primary key. If I misunderstand your meaning, please feel free to correct me.

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us
    Monday, January 9, 2012 5:36 AM
    Moderator

All replies

  • Hi Akoss,

    Welcome to MSDN Forum.

    I'm not clear about the issue. Do you mean you have bind the datasource to your gridview, and you want to edit the record in your gridview. When you turn to Edit mode, the textboxs don't display the values of the record? If I understand correctly, did you store the record's primary key in your gridveiw? If there's a primary key, when you want to modify a record, just query out the recorde from the database through primary key, and assign the record's propery value to the textbox's Text property. After modifying, update the databae through the primary key. If I misunderstand your meaning, please feel free to correct me.

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us
    Monday, January 9, 2012 5:36 AM
    Moderator
  • Hi Akoss,

    Have you solved the issue? I look forward to hearing from you.

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us
    Thursday, January 12, 2012 1:58 AM
    Moderator
  • I didn't solve my problem. Attached a screenshot. I want to edit a selected row under the gridview but in vain click the row in a gridview don't show the datas in the textbox.

    As I see the texbox binding is all right:

    Thursday, January 19, 2012 8:08 AM
  • Hi Akoss,

    Based on the picture you post, I suggest you to ask the question in Windows Form Data Controls and Binding Forum. It's more about binding datasource to a control, so, I think you may get more help from there. I hope the issue can be solved soon.

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us
    Thursday, January 19, 2012 8:34 AM
    Moderator