So I have a RadGrid:
A bunch of Gridbound columns like so:
Here I Created a GripDropDownColumn inside that RadGrid:
And here I attempt to use codebehind to populate this griddropdowncolumn with the following values: Select, Landscape, Portrait.
Both of the datasources I've tried don't work, and I believe it's because I'm not setting ListText and ListValue correctly. Can someone help me fix this so it will work?
Also, when I am in edit mode, I want it to start off selecting the current value, instead of defaulting to "Select".
<telerik:RadGrid ID="RadGridPageDetails" runat="server" DataSourceID="dsReportPageDetail" AllowAutomaticUpdates="True" Width="100%" OnItemCommand="RadGridPageDetails_ItemCommand" OnItemDataBound="RadGridPageDetails_ItemDataBound"><br>
<MasterTableView AutoGenerateColumns="False" DataKeyNames="ReportPageID" DataSourceID="dsReportPageDetail">A bunch of Gridbound columns like so:
<telerik:GridBoundColumn DataField="PageName" FilterControlAltText="Filter PageName column" HeaderText="Section Name" SortExpression="PageName" UniqueName="PageName">
<ColumnValidationSettings>
<ModelErrorMessage Text="" />
</ColumnValidationSettings>
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="PageTitle" FilterControlAltText="Filter PageTitle column" HeaderText="Section Title" SortExpression="PageTitle" UniqueName="PageTitle">
<ColumnValidationSettings>
<ModelErrorMessage Text="" />
</ColumnValidationSettings>
</telerik:GridBoundColumn>Here I Created a GripDropDownColumn inside that RadGrid:
<telerik:GridDropDownColumn DataField="PageOrientation" EnableEmptyListItem="true" EmptyListItemText="--Select--" EmptyListItemValue="" ListTextField="Value" ListValueField="Value" FilterControlAltText="Filter PageOrientation column" HeaderText="Page Orientation" UniqueName="PageOrientation"><ColumnValidationSettings> <ModelErrorMessage Text="" /></ColumnValidationSettings>
</telerik:GridDropDownColumn>And here I attempt to use codebehind to populate this griddropdowncolumn with the following values: Select, Landscape, Portrait.
protected void RadGridPageDetails_ItemDataBound(object sender, GridItemEventArgs e) { if (e.Item is GridEditableItem && (e.Item as GridEditableItem).IsInEditMode) { GridEditableItem editedItem = e.Item as GridEditableItem; GridEditManager editMan = editedItem.EditManager; GridDropDownListColumnEditor editor = editMan.GetColumnEditor("PageOrientation") as GridDropDownListColumnEditor; DataTable dt = new DataTable(); dt.Load(SQLCalls.GetDropdownListValues("Page Orientation")); //This pulls "Landscape" and "Portrait" editor.DataSource = dt; editor.DataSource = new string[] { "Landscape", "Portrait" }; } }Both of the datasources I've tried don't work, and I believe it's because I'm not setting ListText and ListValue correctly. Can someone help me fix this so it will work?
Also, when I am in edit mode, I want it to start off selecting the current value, instead of defaulting to "Select".