I want a button click event inside a Datalist But I am not able to get so this is my code
<asp:DataList ID="OwnArticle" runat="server" OnItemDataBound="OwnArticle_ItemDataBound">
<ItemTemplate>
<table width="100%" cellpadding="3px" cellspacing="0">
<tr>
<td width="20%">
<asp:Image ID="img" runat="server" Height="50px" Width="45px" ImageUrl='<%#"~/UsingID.ashx?id="+ Eval("ID")%>' />
</td>
<td width="80%">
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td width="100%">
<asp:HyperLink ID="hlink" runat="server">
</asp:HyperLink>
</td>
</tr>
<tr>
<td>
<asp:DataList ID="innerRepeater" runat="server">
<ItemTemplate>
<asp:Label ID="lbldesc" runat="server" Text='<%# Eval("Key").ToString()%>'></asp:Label>
</ItemTemplate>
</asp:DataList>
</td>
</tr>
</table>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
<table cellpadding="0" cellspacing="0" width="100%">
<tr>
<td width="10%">
</td>
<td colspan="5" width="90%">
<asp:Label ID="lblArticleName" CssClass="lblCaptionGrey" runat="server" Text='<%# Eval("Article_Name").ToString()%>'></asp:Label>
</td>
</tr>
<tr>
<td width="10%">
</td>
<td colspan="5" width="90%">
<asp:Label ID="Label2" CssClass="lblPara" runat="server" Text='<%# Eval("Article_Desc").ToString()%>'></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Button ID="btnLike" CommandName="isLike" runat="server"
Text="Like" />
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
and codebehind is
protected void ArticleRep_ItemCommand(object source, DataListCommandEventArgs e)
{
if (e.CommandName == "isLike")
{
Response.Write(@"<script language="'javascript'">alert('success.');</script>");
}
else
Response.Write(@"<script language="'javascript'">alert('Error.');</script>");
}
how to get a button click event for the button inside a datalist?
checkout the above code!!??