I have two grid which contains delete button and I am using RadAjaxManager which will fire ajax request from client side to server side OnajaxRequest which contain event handlers and that event handler will call my delete event like below:
<telerik:RadAjaxManager ID="RadAjaxManager2" runat="server" meta:resourcekey="RadAjaxManager1Resource1" OnAjaxRequest="RadAjaxManager2_AjaxRequest">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="RadAjaxManager2">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="Grid1" />
<telerik:AjaxUpdatedControl ControlID="Grid2" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadGrid ID="Grid1" runat="server">
---
---
<telerik:GridTemplateColumn HeaderText="Action" UniqueName="Action" HeaderStyle-Width="130px">
<ItemTemplate>
<asp:ImageButton runat="server" ID="Remove1" Text="Delete" OnClientClick='<%# Eval("Id", "javascript:return DeleteData(\"{0}\");") %>' />
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:RadGrid ID="Grid2" runat="server">
---
---
<telerik:GridTemplateColumn HeaderText="Action" UniqueName="Action" >
<ItemTemplate>
<asp:ImageButton runat="server" ID="Remove2" Text="Delete" OnClientClick='<%# Eval("Id", "javascript:return DeleteData(\"{0}\");") %>' />
</ItemTemplate>
</telerik:GridTemplateColumn>
function DeleteData(Id) {
var ajaxManager = null;
var action = 'Remove';
ajaxManager = $find("ctl00_cphMain_RadAjaxManager2");
var arg = action + "," + Id; //Remove,1(1 indicates id of record to remove from grid)
ajaxManager.ajaxRequest(arg);This line will fire below method.
}
public event EventHandler RemoveEvent;
protected void RadAjaxManager2_AjaxRequest(object sender, AjaxRequestEventArgs e)
{
var argument = (e.Argument);
var stringArray = argument.Split(",".ToCharArray());//[0]="Remove",[1]=1
if (stringArray[0] == "Remove")
{
RemoveEvent(stringArray[1], null);
}
}
After this it will call this:
protected void Page_Load(object sender, EventArgs e)
{
this.RemoveEvent += Remove1_Click;
this.RemoveEvent += Remove2_Click;
if (!IsPostBack)
{
}
}
protected void Remove1_Click(object sender, object obj)
{
}
protected void Remove2_Click(object sender, object obj)
{
}
Problem here is both this events are calling but I just want to call individual delete events on click of Remove1 and Remove2 buttons.