你如何从RadComboBox中读取所选的值?

时间:2015-02-26 21:53:00

标签: asp.net telerik-grid radgrid radcombobox

在RadGrid中,我有一个由Web服务填充的Drop RadboboBox。

我使用嵌套在GridTemplateColumn中的EditItemTemplate来保存它,如图所示:

在服务器端,如何从RadComboBox中访问用户选择的值?

<telerik:GridTemplateColumn UniqueName="UserCol" HeaderText="proto user" DataField="UserID">

                           <EditItemTemplate>
                               <telerik:RadComboBox ID="RadComboBox1" runat="server" AutoPostBack="false" CausesValidation="true"
                                            Width="240" MaxHeight="200px" OnItemsRequested="ddEmployee_ItemsRequested" AllowCustomText="true"
                                            EnableLoadOnDemand="true" ShowMoreResultsBox="true" EnableVirtualScrolling="true"
                                            MarkFirstMatch="false" >
                                </telerik:RadComboBox>
                           </EditItemTemplate>
                       </telerik:GridTemplateColumn>

1 个答案:

答案 0 :(得分:0)

这取决于您正在处理的事件。

您可以设置AutoPostBack =“true”并处理RadComboBox的OnSelectedIndexChanged事件。这非常简单,因为您可以从EventArgs或发件人对象(RadComboBox本身)获取所选值。 看看这个:http://www.telerik.com/help/aspnet-ajax/combobox-server-side-selectedindexchanged.html

如果要处理插入或更新等行操作事件,则需要从GridItem(e.Item)中找到RadComboBox对象。

protected void RadGrid_RowOperation(object sender, Telerik.Web.UI.GridCommandEventArgs e)
{
    // this will find the control 
    RadComboBox RadComboBox1 = (RadComboBox)(e.Item.FindControl("RadComboBox1"));

    // so you can get the selected value
    string value = RadComboBox1.SelectedValue;
}