你怎么看从radcombobox控件选择的价值呢? [英] How do you read the chosen value from a RadComboBox?

查看:261
本文介绍了你怎么看从radcombobox控件选择的价值呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

里面一个radgrid控件,我有一个是通过Web服务人口下降radcombobox控件。

我使用嵌套在一个GridTemplateColumn内的EditItemTemplate中持有它,如下所示:

在服务器端,我怎么能访问来自radcombobox控件由用户选择的值?

 < Telerik的:GridTemplateColumn UniqueName =UserCol的HeaderText =原用户数据字段=用户名>                           <&EditItemTemplate的GT;
                               < Telerik的:radcombobox控件ID =RadComboBox1=服务器的AutoPostBack =假的CausesValidation =真
                                            WIDTH =240了maxHeight =200像素OnItemsRequested =ddEmployee_ItemsRequestedAllowCustomText =真
                                            EnableLoadOnDemand =真ShowMoreResultsBox =真EnableVirtualScrolling =真
                                            MarkFirstMatch =假>
                                < / Telerik的:radcombobox控件>
                           < / EditItemTemplate中>
                       < / Telerik的:GridTemplateColumn>


解决方案

这取决于你正在处理什么事件。

您可以设定的AutoPostBack =true和处理radcombobox控件的事件OnSelectedIndexChanged。这是非常简单的,你可以从EventArgs的或从发送对象,它是radcombobox控件本身获得选择的值。
检查了这一点:的http://www.telerik.com/help/aspnet-ajax/combobox-server-side-selectedindexchanged.html

如果你正在处理一个行操作的事件,如插入或更新,你需要找到在的GridItem(e.Item)的radcombobox控件对象。

 保护无效RadGrid_RowOperation(对象发件人,Telerik.Web.UI.GridCommandEventArgs E)
{
    //这个会发现控制
    radcombobox控件RadComboBox1 =(radcombobox控件)(e.Item.FindControl(RadComboBox1));    //这样你就可以得到价值选择
    字符串值= RadComboBox1.SelectedValue;
}

Inside a RadGrid, I have a drop RadComboBox that is populated by a web service.

I am using an EditItemTemplate nested inside a GridTemplateColumn to hold it, as shown:

On the server side, how can I access the value chosen by the user from the 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>

解决方案

It depends on what event you're handling.

You can set AutoPostBack="true" and handle the OnSelectedIndexChanged event of the RadComboBox. This is very straightforward as you can get the selected value either from the EventArgs or from the sender object which is the RadComboBox itself. Check this out: http://www.telerik.com/help/aspnet-ajax/combobox-server-side-selectedindexchanged.html

If you are handling a row operation event such as insert or update, you need to find the RadComboBox object from the GridItem (e.Item).

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;
}

这篇关于你怎么看从radcombobox控件选择的价值呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆