I have download the Telerik Trail version and tried to use RadGrid. I can able to bind datatable from codebehind but able to execute code on any other grid event like onItemUpdate, onItemDelete and etc. Please check code below
CodeBehind
public void gwList_Delete(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
if (!(new BusinessLogic.LogicClasses.clsUser()).validatePage(Convert.ToInt64(Session["UserID"].ToString()), Page.GetType().Name.Replace("_", "."), BusinessLogic.clsGeneral.RecActionDelete))
{
Response.Redirect("Default.aspx?msg=" + BusinessLogic.clsGeneral.strUnAutherise, true);
}
else
{
BusinessLogic.EntityClasses.clsCity objEDel = new BusinessLogic.EntityClasses.clsCity();
//objEDel.RecID = Convert.ToInt64(gwList.data[e.Item].Values[0].ToString());
objEDel.RUserID = Convert.ToInt64(Session["UserID"].ToString());
long lrt = (new BusinessLogic.LogicClasses.clsCity()).Delete(objEDel);
if (lrt > 0)
(new clsFunctions()).SetMessage(BusinessLogic.clsGeneral.strSuccess, Master);
else
(new clsFunctions()).SetMessage(BusinessLogic.clsGeneral.strUnSuccess, Master);
LoadGrid();
}
ASPX:
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="gwList">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="gwList" />
</UpdatedControls>
</telerik:AjaxSetting>
<telerik:AjaxSetting AjaxControlID="RadGrid2">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="RadGrid2" LoadingPanelID="RadAjaxLoadingPanel1" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel2" runat="server" />
<telerik:RadGrid ID="gwList" EnableViewState="true" runat="server" AllowPaging="true"
AllowSorting="True" AllowFilteringByColumn="false" GridLines="None"
AutoGenerateColumns="false" AllowAutomaticDeletes="true"
OnItemDeleted="gwList_delete">
<MasterTableView AllowMultiColumnSorting="true" TableLayout="Fixed" EditMode="EditForms"
AllowFilteringByColumn="true" DataSourceID="" AllowPaging="true">
<Columns>
<telerik:GridBoundColumn DataField="City" HeaderText="City" HeaderStyle-Width="100px"
FilterControlWidth="50px" AllowFiltering="true">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Country" HeaderText="Country" AllowFiltering="true">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Miki" HeaderText="Miki" AllowFiltering="true">
</telerik:GridBoundColumn>
<telerik:GridButtonColumn ConfirmText="Delete this product?" ConfirmDialogType="RadWindow"
ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete"
UniqueName="Miki" >
<ItemStyle HorizontalAlign="Center" CssClass="MyImageButton"></ItemStyle>
</telerik:GridButtonColumn>
<telerik:GridEditCommandColumn >
</telerik:GridEditCommandColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
</telerik:RadAjaxLoadingPanel>
CodeBehind
public void gwList_Delete(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
if (!(new BusinessLogic.LogicClasses.clsUser()).validatePage(Convert.ToInt64(Session["UserID"].ToString()), Page.GetType().Name.Replace("_", "."), BusinessLogic.clsGeneral.RecActionDelete))
{
Response.Redirect("Default.aspx?msg=" + BusinessLogic.clsGeneral.strUnAutherise, true);
}
else
{
BusinessLogic.EntityClasses.clsCity objEDel = new BusinessLogic.EntityClasses.clsCity();
//objEDel.RecID = Convert.ToInt64(gwList.data[e.Item].Values[0].ToString());
objEDel.RUserID = Convert.ToInt64(Session["UserID"].ToString());
long lrt = (new BusinessLogic.LogicClasses.clsCity()).Delete(objEDel);
if (lrt > 0)
(new clsFunctions()).SetMessage(BusinessLogic.clsGeneral.strSuccess, Master);
else
(new clsFunctions()).SetMessage(BusinessLogic.clsGeneral.strUnSuccess, Master);
LoadGrid();
}
ASPX:
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="gwList">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="gwList" />
</UpdatedControls>
</telerik:AjaxSetting>
<telerik:AjaxSetting AjaxControlID="RadGrid2">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="RadGrid2" LoadingPanelID="RadAjaxLoadingPanel1" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel2" runat="server" />
<telerik:RadGrid ID="gwList" EnableViewState="true" runat="server" AllowPaging="true"
AllowSorting="True" AllowFilteringByColumn="false" GridLines="None"
AutoGenerateColumns="false" AllowAutomaticDeletes="true"
OnItemDeleted="gwList_delete">
<MasterTableView AllowMultiColumnSorting="true" TableLayout="Fixed" EditMode="EditForms"
AllowFilteringByColumn="true" DataSourceID="" AllowPaging="true">
<Columns>
<telerik:GridBoundColumn DataField="City" HeaderText="City" HeaderStyle-Width="100px"
FilterControlWidth="50px" AllowFiltering="true">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Country" HeaderText="Country" AllowFiltering="true">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Miki" HeaderText="Miki" AllowFiltering="true">
</telerik:GridBoundColumn>
<telerik:GridButtonColumn ConfirmText="Delete this product?" ConfirmDialogType="RadWindow"
ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete"
UniqueName="Miki" >
<ItemStyle HorizontalAlign="Center" CssClass="MyImageButton"></ItemStyle>
</telerik:GridButtonColumn>
<telerik:GridEditCommandColumn >
</telerik:GridEditCommandColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
</telerik:RadAjaxLoadingPanel>