GridDropDownColumn in RadGrid

4 posts, 1 answers
  1. Michael Nagy
    Michael Nagy avatar
    18 posts
    Member since:
    May 2008

    Posted 22 Oct 2008 Link to this post

    Hello ,
    i working with RadGrid but i have a problem could any one help me to resolve it .
    i have RadGrid and i set it's data source with list of business objects

         <telerik:RadGrid ID="RadGrid1" runat="server" Skin="Default2006" GridLines="None"
                AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" Width="500px"
                ShowStatusBar="True" OnPreRender="RadGrid1_PreRender" OnNeedDataSource="RadGrid1_NeedDataSource"
                OnUpdateCommand="RadGrid1_UpdateCommand" OnInsertCommand="RadGrid1_InsertCommand"
                OnDeleteCommand="RadGrid1_DeleteCommand" OnItemDataBound="RadGrid1_ItemDataBound">
                <mastertableview gridlines="None" commanditemdisplay="Top" datakeynames="ACC_ID">
                    <RowIndicatorColumn>
                        <HeaderStyle Width="20px"></HeaderStyle>
                    </RowIndicatorColumn>
                    <ExpandCollapseColumn>
                        <HeaderStyle Width="20px"></HeaderStyle>
                    </ExpandCollapseColumn>
                    <Columns>
                        <telerik:GridEditCommandColumn UniqueName="EditCommandColumn">
                        </telerik:GridEditCommandColumn>
                        <telerik:GridBoundColumn HeaderText="NAME" UniqueName="NAME" DataField="Name">
                        </telerik:GridBoundColumn>                    
                        <telerik:GridDropDownColumn
                            DropDownControlType="DropDownList"
                            HeaderText="TYPE"
                            UniqueName="ACC_TYPE" DataField="CRM_ACC_TYPE"  
                            ListTextField="NAME" ListValueField="TYPE_ID">
                        </telerik:GridDropDownColumn>
                        <telerik:GridButtonColumn UniqueName="DeleteColumn" Text="Delete"
                            CommandName="Delete" ConfirmDialogType="RadWindow" />
                    </Columns>
                    <EditFormSettings>
                        <EditColumn UniqueName="EditCommandColumn1">
                        </EditColumn>
                    </EditFormSettings>
                </mastertableview>
                <filtermenu skin="Vista" enabletheming="True">
                    <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
                </filtermenu>
            </telerik:RadGrid>

    CRM_ACC_TYPE is a property at data item and it is an object also conatin 2 property NAME and TYPE_ID



    i faced problem at GridDropDownColumn when  data grid bound i cann't see the Name of  CRM_ACC_TYPE in the  GridDropDownColumn in view mode it is empty.

    and in edit mode i bound the GridDropDownColumn in RadGrid1_ItemDataBound Event some thing like that

        protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
            {
    if (e.Item is GridEditableItem && (e.Item as GridEditableItem).IsInEditMode)
                {
                    GridEditableItem editedItem = e.Item as GridEditableItem;
                    GridEditManager editMan = editedItem.EditManager;

                    GridDropDownColumnEditor editor = editMan.GetColumnEditor("ACC_TYPE") as GridDropDownColumnEditor;
                    editor.DataSource = enties.CRM_ACC_TYPE;
                    editor.DataTextField = "NAME";
                    editor.DataValueField = "TYPE_ID";
                    editor.DataBind();
                }
    }




  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 22 Oct 2008 Link to this post

    Hello Michael,

    Try binding the Literal present in the normal mode of the GridDropDownColumn as shown below.
    aspx:
    <telerik:GridDropDownColumn UniqueName="ComboBox" >         
            </telerik:GridDropDownColumn> 

    cs:
     protected void RadGrid2_ItemDataBound(object sender, GridItemEventArgs e) 
        { 
            if (e.Item is GridDataItem && !e.Item.IsInEditMode) 
            { 
                GridDataItem dataItem = (GridDataItem)e.Item; 
                Literal litrlContrl = (Literal)dataItem["ComboBox"].Controls[0]; 
                litrlContrl.Text = DataBinder.Eval(dataItem.DataItem, "CRM_ACC_TYPE").ToString(); 
            } 
       } 

    Thanks
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Michael Nagy
    Michael Nagy avatar
    18 posts
    Member since:
    May 2008

    Posted 22 Oct 2008 Link to this post

    Thanks so much .. great answer its working

    but i want to ask anther question

    in the same grid
    i have GridBoundColumn called NAME

    <telerik:GridBoundColumn HeaderText="NAME" UniqueName="NAME" DataField="Name">
                        </telerik:GridBoundColumn> 


    i need to change in edit template i need to show rich text box instead of text box :)
  5. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 23 Oct 2008 Link to this post

    Hello Michael,

    You can go through the following help article link which explains how to implement custom column editors.
    Custom editors extending auto-generated editors

    Regards,
    Princy.
Back to Top