Hi,
I'm using the RadGrid to populate a list of objects; Document.
I'll like to make every row editable, but currently only the last row has the GridDropDownColumn enabled.
Please help!.
Thanks!
I'm using the RadGrid to populate a list of objects; Document.
I'll like to make every row editable, but currently only the last row has the GridDropDownColumn enabled.
Please help!.
Thanks!
<telerik:RadGrid ID="RadGridDocuments" runat="server" CellSpacing="-1" GridLines="Both" AutoGenerateColumns="false" OnItemDataBound="RadGridDocuments_ItemDataBound" OnPreRender="RadGridDocuments_PreRender"> <ClientSettings AllowColumnsReorder="True" ReorderColumnsOnClient="True"> <Selecting AllowRowSelect="True" /> </ClientSettings> <MasterTableView EditMode="InPlace"> <Columns> <telerik:GridBoundColumn DataField="FileName" HeaderText="File Name" UniqueName="FileName" ReadOnly="true"> </telerik:GridBoundColumn> <telerik:GridDropDownColumn UniqueName="Type" HeaderText="Type" DataField="Type" EmptyListItemText="--Choose an option--" EmptyListItemValue=""> </telerik:GridDropDownColumn> </Columns> </MasterTableView> </telerik:RadGrid>protected void ButtonAddDetails_Click(object sender, EventArgs e) { List<Document> docs = new List<Document>(); foreach (UploadedFile f in RadAsyncUploadDocuments.UploadedFiles) { docs.Add(new Document(f)); } RadGridDocuments.DataSource = docs; RadGridDocuments.DataBind(); } protected void RadGridDocuments_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) { if (e.Item is GridEditableItem && e.Item.IsInEditMode) { GridEditableItem editedItem = e.Item as GridEditableItem; GridEditManager editMan = editedItem.EditManager; GridDropDownListColumnEditor editor = (GridDropDownListColumnEditor)(editMan.GetColumnEditor("Type")); //in case you have RadComboBox editor for the GridDropDownColumn (this is the default editor), //you will need to use ComboBoxControl below instead of DropDownListControl //and add RadComboBoxItems instead of ListItems to the Items collection of the editor editor.ComboBoxControl.Items.Add(new RadComboBoxItem("FAA Administrator's Order", "FAA Administrator's Order")); editor.ComboBoxControl.Items.Add(new RadComboBoxItem("Notice of Appeal", "Notice of Appeal")); } } protected void RadGridDocuments_PreRender(object sender, System.EventArgs e) { foreach (GridItem item in RadGridDocuments.MasterTableView.Items) { if (item is GridEditableItem) { GridEditableItem editableItem = item as GridDataItem; editableItem.Edit = true; } } RadGridDocuments.Rebind(); }public class Document { private UploadedFile file; private string type; public Document(UploadedFile file) { this.file = file; this.type = string.Empty; } public UploadedFile File { get { return this.file; } } public string FileName { get { return this.file.FileName; } } public string Type { get { return this.type; } set { this.type = value; } } }