如何填写telerik网格数据库中的下拉列表?

时间:2014-06-10 04:24:16

标签: c# asp.net vb.net telerik dotnetnuke

我有一个telerik网格,并使用GridTemplateColumn作为下面的

<telerik:GridTemplateColumn DataField="Status" ReadOnly="true" UniqueName="colStatus" HeaderText="Status">  
    <ItemTemplate>
        <asp:Label ID="lblStatus" runat="server"></asp:Label>
    </ItemTemplate>
    <EditItemTemplate>
        <asp:DropDownList ID="drpstatus" runat="server" />
    </EditItemTemplate>                                    
</telerik:GridTemplateColumn> 

然后我在ItemDataBound事件中填写下拉列表和标签:

protected void grdList_ItemDataBound(object sender, GridItemEventArgs e)
{

            if (e.Item.ItemType == GridItemType.Item || e.Item.ItemType == GridItemType.AlternatingItem)
            {
                if (e.Item is GridEditableItem && e.Item.IsInEditMode)
                {
                    GridEditableItem editItem = (GridEditableItem)e.Item;
                    var info = (ProductViewInfo)e.Item.DataItem;
                    DropDownList drpstatus = (DropDownList)editItem["colStatus"].FindControl("drpstatus");
                    var cntType = new ProductTypeController();
                    var lst = cntType.GetStatusList(PortalId, enumTypes.MainGroup);
                    drpstatus.DataSource = lst;
                    drpstatus.DataTextField = "Caption";
                    drpstatus.DataValueField = "StatusID";
                    drpstatus.DataBind();
                    drpstatus.SelectedValue = info.Status.ToString();
                }
                else
                {
                    var item = e.Item as GridDataItem;
                    var info = (ProductViewInfo)item.DataItem;

                    Label lblStatus = (Label)item["colStatus"].FindControl("lblStatus"); 
                    lblStatus.Text = info.StatusCaption;
                }
            }
 }

但我的下拉不填! “e.Item.IsInEditMode”始终返回false。我应该添加其他任何内容以填充下拉列表吗?

1 个答案:

答案 0 :(得分:0)

我猜问题与ReadOnly="true"有关 试着删除它