简体   繁体   中英

Telerik access to RadComboBox inside RadGrid

My code is almost identical to this demo: https://demos.telerik.com/aspnet-ajax/grid/examples/overview/defaultcs.aspx

The question is how can I access brand RadComboBox inside the RadGrid. If use it outside - it works OK, but if it is inside the grid, aspx.cs can't find the item by id. The main problem I have - I want to create also a model field. And when the brand changes (for example Mercedes) I want to show models only for mercedes, and not bmw, opel and so on. I want the model to be select only like a brand field.

You can check the following resources on the matter:

RadComboBox in RadGrid Accessing RadComboBox in codebehind from a RadGrid

protected void OnItemDataBoundHandler(object sender, GridItemEventArgs e)
{
    if (e.Item.IsInEditMode)
    {
        GridEditableItem item = (GridEditableItem)e.Item;
        if (!(e.Item is IGridInsertItem))
        {
            RadComboBox combo = (RadComboBox)item.FindControl("RadComboBox1");
            RadComboBoxItem selectedItem = new RadComboBoxItem();
            selectedItem.Text = ((DataRowView)e.Item.DataItem)["CompanyName"].ToString();
            selectedItem.Value = ((DataRowView)e.Item.DataItem)["SupplierID"].ToString();
            selectedItem.Attributes.Add("ContactName", ((DataRowView)e.Item.DataItem)["ContactName"].ToString());
            combo.Items.Add(selectedItem);
            selectedItem.DataBind();
            Session["SupplierID"] = selectedItem.Value;
        }
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM