You have use IPostBackEventHandler interface for this
This Way:
Reference:
http://stackoverflow.com/questions/5419115/table-row-onclick-event-that-runs-codebehind
<form id="form1" runat="server">
<asp:Repeater ID="rptDemo" runat="server">
<ItemTemplate>
<table>
<tr onclick="<%= _jsPostBackCall %>;">
<td>
<asp:Label Text='<%# Eval("Alphabets") %>' runat="server" />
</td>
</tr>
</table>
</ItemTemplate>
</asp:Repeater>
<h1>
<asp:Literal ID="litMessage" runat="server" />
</h1>
<asp:Button Text="Save" runat="server" />
</form>
C#:
public partial class TableRowEvent : System.Web.UI.Page, IPostBackEventHandler
{
protected String _jsPostBackCall;
protected void Page_Load(object sender, EventArgs e)
{
// "myTr" will be passed as an argument to RaisePostBackEvent method
_jsPostBackCall = ClientScript.GetPostBackEventReference(this, "myTr");
if (!this.IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.Add("Alphabets", typeof(string));
dt.Rows.Add("A");
dt.Rows.Add("B");
dt.Rows.Add("C");
this.rptDemo.DataSource = dt;
this.rptDemo.DataBind();
}
}
public void RaisePostBackEvent(string eventArgument)
{
switch (eventArgument)
{
case "myTr":
HandleTrClick();
break;
// you can add other controls that need postback processing here
default:
throw new ArgumentException();
}
}
private void HandleTrClick()
{
litMessage.Text = "Tr clicked.";
}
}
Thank You.