Hi,
I am using the RadGrid control to show some very basic data and allow users to insert new items and edit existing ones. I have had a look at the documentation and demos concerning inserting but I seem to be running into a problem. No matter what I try the new value is returned as null. Please find my code below:
Markup:
Code behind:
My ItemBasket class handles the creation if the basket and all it needs is a name. The problem is that the value is always null and therefore the AddBasket method throws an exception.
I have also tried:
Here the value is in the hashtable but it is null again. I am obviously missing something here, advice would be welcome.
Chris
I am using the RadGrid control to show some very basic data and allow users to insert new items and edit existing ones. I have had a look at the documentation and demos concerning inserting but I seem to be running into a problem. No matter what I try the new value is returned as null. Please find my code below:
Markup:
<telerik:RadGrid ID="RadGrid_Baskets" runat="server" AutoGenerateColumns="False" CssClass="basket_grid" DataKeyNames="id"> <ClientSettings Selecting-AllowRowSelect="true" EnablePostBackOnRowClick="true" ClientEvents-OnRowClick="RadGrid_Basket_OnRowClick"/> <MasterTableView CommandItemDisplay="Top"> <Columns> <telerik:GridBoundColumn DataField="name" HeaderText="Basket Name" UniqueName="name"/> <telerik:GridTemplateColumn Display="false" ReadOnly="true"> <ItemTemplate> <input type="hidden" id="item_id_hidden_<%#eval("id")%>" class="item_id" value="<%#eval("id")%>" /> </ItemTemplate> </telerik:GridTemplateColumn> <telerik:GridTemplateColumn> <ItemTemplate> <asp:LinkButton ID="ImageButton_Edit" runat="server" CommandName="Edit" Text="Edit" Visible='<%#Not IsSystemBasket(Eval("name"))%>'/> </ItemTemplate> </telerik:GridTemplateColumn> <telerik:GridTemplateColumn UniqueName="DeleteColumn"> <ItemTemplate> <asp:ImageButton ID="ImageButton_Delete" runat="server" CommandName="Delete" ImageUrl="../Objects/CSS/telerik/Grid/Delete.gif" Text="Delete" Visible='<%#Not IsSystemBasket(Eval("name"))%>'/> </ItemTemplate> </telerik:GridTemplateColumn> </Columns> </MasterTableView> </telerik:RadGrid>Code behind:
Protected Sub RadGrid_Basket_InsertCommand(ByVal source As Object, ByVal e As GridCommandEventArgs) Handles RadGrid_Baskets.InsertCommandDim newItem As GridEditableItem = CType(e.Item, GridEditableItem)Dim editManager As GridEditManager = newItem.EditManagerDim editor As GridTextBoxColumnEditor = editManager.GetColumnEditor(e.Item.OwnerTableView.RenderColumns(2))ItemBaskets.AddBasket(editor.Text)End SubMy ItemBasket class handles the creation if the basket and all it needs is a name. The problem is that the value is always null and therefore the AddBasket method throws an exception.
I have also tried:
Protected Sub RadGrid_Basket_InsertCommand(ByVal source As Object, ByVal e As GridCommandEventArgs) Handles RadGrid_Baskets.InsertCommandDim newItem As GridEditableItem = CType(e.Item, GridEditableItem)Dim values As New Hashtable()e.Item.OwnerTableView.ExtractValuesFromItem(values, newItem)ItemBaskets.AddBasket(values("name"))End SubHere the value is in the hashtable but it is null again. I am obviously missing something here, advice would be welcome.
Chris