This is a migrated thread and some comments may be shown as answers.

combo box two way binding not passing new selected value to save function , old value is being captured

1 Answer 326 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Georges
Top achievements
Rank 1
Georges asked on 08 Sep 2016, 07:01 PM
Hi i have the two way binding working with rad grid and a rad combobox in a template but when i hit  save the new changed data is not being passed. i keep getting the old bound data. here is the code.                           
                                       
    protected void OnClickSave(object sender, EventArgs e)
        {
            foreach (var test in grdStatus.Items)
            {
              GridEditableItem item = (GridEditableItem)test;
               QARSubmittal s = item.DataItem as QARSubmittal;
                RadComboBox comboBox = item.FindControl("CbOracleVerified") as RadComboBox;

               string format = DataBinder.Eval(item.DataItem, "ORACLE_VERIFIED").ToString(); 

            }

        }
    private void LoadResults()
        {
            var dtosList = new List<QARSubmittal>();
            int counter = 3;
            for (int i = 0; i < counter; i++)
            {
                var dtos = new QARSubmittal
                {

                    AUDIT_CALENDAR_ID = 11000+i,
                    SUBMITTER_USERID = 1000 + i,
                    RC = 999 + i,
                    STATION = "Atlanta" + i,              
                    ORACLE_VERIFIED = i==1?0:1,
                    TRAFFIC_VERIFIED = 1,
                    DART_VERIFIED = 1,
                    OPERATIVE_VERIFIED = 1,
                    CBSPAYNOW_VERIFIED = 1,
                    ANDO_TRITON_VERIFIED = 1,
                    SUBMITTAL_STATUS = 1000,
                    SUBMITTER = "gabdo" + i,
                    SUBMIT_DATE = DateTime.Today,
                    MARKET = "Atlanta" + i

                };
                dtosList.Add(dtos);
            }

            grdStatus.DataSource = dtosList;
            grdStatus.Rebind();

        }


here is my html 
                                       
             <telerik:RadGrid runat="server" ID="grdStatus" OnItemCommand="grdStatus_ItemCommand"   AutoGenerateColumns="false"  AllowPaging="false" >
                   <MasterTableView DataKeyNames="QAR_SUBMITTAL_ID,AUDIT_CALENDAR_ID,SUBMITTER_USERID,RC, MARKET, STATION, ORACLE_VERIFIED, TRAFFIC_VERIFIED,
                ANDO_TRITON_VERIFIED,DART_VERIFIED,OPERATIVE_VERIFIED,CBSPAYNOW_VERIFIED,SUBMITTER">
                   <Columns>
                    
                         <telerik:GridTemplateColumn UniqueName="ORACLE_VERIFIED" HeaderText="Oracle">
                        <ItemTemplate>
                                <telerik:RadComboBox runat="server" SelectedValue='<%#Bind("ORACLE_VERIFIED") %>' AutoPostBack="false" ID="CbOracleVerified">
                                <Items>
                                    <telerik:RadComboBoxItem Text="Not Verified" Value="0" />
                                     <telerik:RadComboBoxItem Text="N/A" Value="-1" />
                                     <telerik:RadComboBoxItem Text="Verified" Value="1" />
                                     
                                </Items>
                      </telerik:RadComboBox>
                         
                   </Columns>
                       </MasterTableView>
             </telerik:RadGrid>

     <div class="dialogHeader">
        <table border="0">
            <tr>
                <td align="left" valign="top">
                    <table cellspacing="5">
                        <tr>
                            <td>
                                <telerik:RadButton runat="server" ID="btnSave" OnClick="OnClickSave" Text="Save" Style="margin-bottom: 0px">
                                </telerik:RadButton>
                            </td>
                            <td>
                                <telerik:RadButton runat="server" ID="btnSubmit" OnClick="OnClickSubmit" Text="Submit">
                                </telerik:RadButton>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    </div>

1 Answer, 1 is accepted

Sort by
0
Veselin Tsvetanov
Telerik team
answered on 13 Sep 2016, 10:41 AM
Hi Georges,

The approach chosen won't let you achieve the desired modification of the value for the specific grid row. You will need to place the RadComboBox in an EditItemTemplate and only evaluate the selected value in the ItemTemplate. Possible implementation of similar scenario, could be observed in the following RadGrid demo.

Regards,
Veselin Tsvetanov
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
ComboBox
Asked by
Georges
Top achievements
Rank 1
Answers by
Veselin Tsvetanov
Telerik team
Share this question
or