Hello!
I currently have a RadGrid bound to a List containing a custom class. This list gets populated when a user drags a node from a TreeView.
I'd like to let the user select a value from the dropdown and enter their own value inside the "Value" field and then save this to the List.
I've tried doing this using the automatic edit column but inside the "RadGrid_UpdateCommand" I can't seem to find the new data! I'm probably missing something pretty simple. :)
Here's the code:
<telerik:RadGrid ID="conditionsGrid" runat="server" Width="252px" |
Height="116px" GridLines="None" AllowMultiRowSelection="True" |
onneeddatasource="conditionsGrid_NeedDataSource" Skin="Sunset" CssClass="addedTablesGrid" |
AutoGenerateEditColumn="True" onitemupdated="conditionsGrid_ItemUpdated" |
onupdatecommand="conditionsGrid_UpdateCommand" |
AllowAutomaticUpdates="true" onitemcommand="conditionsGrid_ItemCommand"> |
<MasterTableView Width="100%"> |
<NoRecordsTemplate> |
Drag columns here. |
</NoRecordsTemplate> |
<Columns> |
<telerik:GridBoundColumn HeaderText="Column" UniqueName="columnColumn" DataField="columnName" DataType="System.String" EmptyDataText="Ooops" ReadOnly="true"> |
</telerik:GridBoundColumn> |
<telerik:GridTemplateColumn HeaderText="Value" UniqueName="type1"> |
<ItemTemplate> |
<asp:DropDownList runat="server"> |
<asp:ListItem Text="Equals" Value="="></asp:ListItem> |
<asp:ListItem Text="Greater than" Value=">"></asp:ListItem> |
<asp:ListItem Text="Less than" Value="<"></asp:ListItem> |
<asp:ListItem Text="Not equal to" Value="!="></asp:ListItem> |
</asp:DropDownList> |
</ItemTemplate> |
</telerik:GridTemplateColumn> |
<telerik:GridBoundColumn HeaderText="Value" UniqueName="valueColumn" DataField="value" > |
</telerik:GridBoundColumn> |
</Columns> |
</MasterTableView> |
<ClientSettings AllowRowsDragDrop="true"> |
<Selecting AllowRowSelect="true" EnableDragToSelectRows="true" /> |
</ClientSettings> |
</telerik:RadGrid> |
protected void ColumnTreeView_NodeDrop(object sender, RadTreeNodeDragDropEventArgs e) |
{ |
if (string.IsNullOrEmpty(e.HtmlElementID)) |
return; |
if (e.HtmlElementID == "MainBodyPlaceHolder_conditionsGrid") |
{ |
List<GridConditionRow> added = AddedTableConditions; |
foreach (RadTreeNode node in e.DraggedNodes) |
{ |
GridConditionRow Row = new GridConditionRow(); |
Row.columnName = node.Value; |
Row.value = ""; |
added.Add(Row); |
} |
AddedTableConditions = added; |
conditionsGrid.DataSource = AddedTableConditions; |
conditionsGrid.DataBind(); |
} |
} |
protected void conditionsGrid_UpdateCommand(object source, GridCommandEventArgs e) |
{ |
//It's here that I can't seem to find the updated information to alter the List with. |
} |
Thanks!
Ben.