This is a migrated thread and some comments may be shown as answers.

GridDropDownColumn in RadGrid

3 Answers 90 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Michael Nagy
Top achievements
Rank 2
Michael Nagy asked on 22 Oct 2008, 01:14 PM
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();
            }
}




3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 22 Oct 2008, 01:42 PM
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.
0
Michael Nagy
Top achievements
Rank 2
answered on 22 Oct 2008, 02:16 PM
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 :)
0
Accepted
Princy
Top achievements
Rank 2
answered on 23 Oct 2008, 07:38 AM
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.
Tags
Grid
Asked by
Michael Nagy
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
Michael Nagy
Top achievements
Rank 2
Share this question
or