【问题标题】:How do you read the chosen value from a RadComboBox?您如何从 RadComboBox 中读取所选值?
【发布时间】:2015-02-26 21:52:59
【问题描述】:

在 RadGrid 中,我有一个由 Web 服务填充的下拉 RadComboBox。

我正在使用嵌套在 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>

【问题讨论】:

  • 你是怎么做到的?如果对您有帮助,您能否接受我的回答,或者发表评论或投票之类的。这样其他有类似问题的人也能从中受益。

标签: asp.net telerik-grid radgrid radcombobox


【解决方案1】:

这取决于您要处理的事件。

您可以设置 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;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-08-05
    • 1970-01-01
    • 2017-01-31
    • 2015-04-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多