Newbie question about binding Radcombobox embedded in Radgrid to Radgrid Value

2 posts, 0 answers
  1. Neil
    Neil avatar
    14 posts
    Member since:
    Mar 2019

    Posted 24 Jun 2019 Link to this post


            Very new to telerik. I have a radgrid that has a radcombobox in each row using an edititemtemplate. For each row I'm trying to get the value in the data source for the radgrid and then set the radcombobox to that same value. Eventually I want to choose a value from the radcombox and save the grid using that value for that same field in the radgrid. So there is one field in the radgrid that is always tied to the radcombobox for any row

       After some digging I figured out how to get the value in the radgrid for the field I want in the ItemDatabound event:

                if (e.Item is GridDataItem)


                    GridDataItem item = (GridDataItem)e.Item;
                    string Line = item.GetDataKeyValue("WO_ID").ToString();
                    //string MachineID = (item["Machine"].Controls[0]).ToString();
                    string s = ((DataRowView)e.Item.DataItem)["MachineID"].ToString();
                    RadComboBox cboMachine = item.FindControl("cboMachine") as RadComboBox;
                    cboMachine.SelectedValue = s;


    What I would like to do now is take the the "s" variable and set the combobox to that value (this would be on the first display of the screen). As you can see in the line:

     cboMachine.SelectedValue = s;

    I was attempting to set the combobox to the value that is read into the radgrid;unfortunately the findcontrol I used did not find the combobox control. What I think I found in my naive understanding of this is that I couldn't get to combo box as a control and set it as long as I was using this if statement

    "if (e.Item is GridDataItem)"

    It seemed I need to use GridEditFormItem.The problem is that would involve require another call to ItemDataBound and I'd lose the value I got from the grid is the variable "s". I suppose I could make "s" a session variable but that seems clumsy and not decent design. I'm sure I'm missing something.

    Any help  would be appreciated.





  2. Eyup
    Eyup avatar
    3955 posts

    Posted 27 Jun 2019 Link to this post

    Hi Neil,

    Thank you for elaborating Telerik to be your default .NET development tools provider. There might be some minor learning curve at first, but after some time when you get used to Telerik UI Controls, they will become your favorite software and web development assistants. We, the Telerik support team, will be here to assist you when necessary.

    Implementing a combo or dropdown for editing grid records is a common task and you can find all the required information here:

    You can use the DataBinding event handler of the dropdownlist to make your custom query and provide the result as its DataSource.
    If you are using the EnableLoadOnDemand property of the combo, you can use the Text='<%# Bind("MyFieldName") %>' instead of SelectedValue. Or you can use the PreRender event handler as demonstrated in the attached web site sample.

    I hope this will prove helpful.

    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top