Saving gridview with combobox columns giving null values

2 posts, 1 answers
  1. Sree
    Sree avatar
    30 posts
    Member since:
    Dec 2012

    Posted 12 Sep 2013 Link to this post

    Hello Telerik Team,
     i have some issues with the comobobox column of radgridview for winforms

    here is the below code

                    GridViewComboBoxColumn colLithography = new GridViewComboBoxColumn();
                    colLithography.DataType = typeof(string);
                    colLithography.DataSource = dt; // dt is having only one Column called Name
                    colLithography.HeaderText = "Lithography";
                    colLithography.ValueMember = "Name";
                    colLithography.DisplayMember = "Name";
                    colLithography.FieldName = "Name";
                    this.rGVPP.Columns.Insert(2, colLithography); // rGVPP is Radgridview

    Above code perfectly added the values to the combobox

    but now i want to save the gridview data to database,

    So in Btn_Save click i am reading sending the gridview values to a query like below, observe the debug at break point which is the code
    and in the quick watch window the value is null, throwing exception here

    but my grid having values in all the cell, when i try to read the value of a particular cell of combobox column, its giving null value.

    Please help me.
  2. Answer
    Nikolay avatar
    1802 posts

    Posted 17 Sep 2013 Link to this post

    Hi Sree,

    You can get a cell from the Cells of a row passing the Name property value of its column rather than the name of the column instance. I can see that there is no Name set for your column, so you need to set one. Considering the column definition from the beginning of this article we would take the cell by Cells["SupplierColumn"]. 

    I hope this helps. Let me know if you have additional questions.

    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. DevCraft banner
Back to Top