Hi,
I have a radgrid, with a delete option as below:
The following is the delete code in c#:
However when i try this, i get an JS error as attached.
Please suggest.
Thanks,
Debashis
I have a radgrid, with a delete option as below:
<telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager> <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"> <AjaxSettings> <telerik:AjaxSetting AjaxControlID="pnlMaster"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="pnlMaster" /> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings> </telerik:RadAjaxManager> <telerik:RadGrid ID="grdCompanyList" runat="server" GridLines="None" AutoGenerateColumns="False" AllowSorting="True" AllowFilteringByColumn = "True" AllowPaging="True" EnableLinqExpressions="False" PageSize="10" OnNeedDataSource="grdCompanyList_NeedDataSource" OnItemDataBound="grdCompanyList_ItemDataBound" OnItemCommand = "grdCompanyList_ItemCommand"> <PagerStyle Mode="NextPrevAndNumeric"></PagerStyle> <MasterTableView DataKeyNames="watchlist_id" CommandItemDisplay="Top" EditMode="PopUp"> <CommandItemSettings ShowAddNewRecordButton="false"/> <Columns> <telerik:GridBoundColumn DataField="watchlist_id" DataType="System.Int32" HeaderText="watchlist_id" ReadOnly="True" SortExpression="watchlist_id" UniqueName="watchlist_id" Visible="false" > </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="company_id" DataType="System.Int32" HeaderText="company_id" ReadOnly="True" SortExpression="company_id" UniqueName="company_id" Visible="false" > </telerik:GridBoundColumn> <telerik:GridTemplateColumn AllowFiltering="false" ItemStyle-Width="180px"> <ItemTemplate> <asp:Image width="142" height="58" ID="CompLogos" ImageUrl="<%# showCompLogo(Container.DataItem) %>" runat="server" AlternateText="Logo" /> </ItemTemplate> </telerik:GridTemplateColumn> <telerik:GridBoundColumn DataField="company_name" HeaderText="Company name" SortExpression="company_name" ItemStyle-Width="450" UniqueName="company_name" ReadOnly="true"> <ItemStyle Width="450px" /> </telerik:GridBoundColumn> <telerik:GridTemplateColumn AllowFiltering="false" ItemStyle-Width="150px" HeaderText="Actions"> <ItemTemplate> <div> <span style="padding:0 5px"> <asp:HyperLink ID="CoLink" runat="server" ImageUrl="~/images/viewicon_big.png" ToolTip="View Details"></asp:HyperLink> </span> <span style="padding:0 5px"> <asp:ImageButton runat="server" ID="DelButton" ImageUrl="~/images/delete-32.png" ToolTip="Delete" CausesValidation="false" CommandName="Delete" /> </span> </div> </ItemTemplate> </telerik:GridTemplateColumn> </Columns> </MasterTableView> <ClientSettings EnableRowHoverStyle="true"></ClientSettings> </telerik:RadGrid>The following is the delete code in c#:
protected void grdCompanyList_ItemCommand(object sender, GridCommandEventArgs e) { if (e.CommandName == RadGrid.DeleteCommandName) { GridDataItem item = (GridDataItem)e.Item; string iWatch = item["watchlist_id"].Text; Power50MiddleWare.BL.Watchlist oWatch = new Power50MiddleWare.BL.Watchlist(); oWatch._WatchlistId = Int32.Parse(iWatch); try { int retResult = oWatch.RemoveWatchlist(); if (retResult == 1) { GenerateWatchlist(); pnlMsg.Visible = true; lblMsg.Text = "Successfully deleted your watchlist item"; } else { pnlMsg.Visible = true; lblMsg.Text = "Sorry could not delete the item, please contact your system administrator"; } } catch (System.Exception exp) { pnlMsg.Visible = true; lblMsg.Text = exp.Message.ToString() + exp.StackTrace; } }However when i try this, i get an JS error as attached.
Please suggest.
Thanks,
Debashis
