i wand to find id of user post in repeater control , for that i used hidden field control but returns only first id of item in repeater on itemcommand event
<asp:Repeater runat="server" ID="RepLeft" onitemcommand="RepLeft_ItemCommand"
onitemdatabound="RepLeft_ItemDataBound">
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>
<asp:HiddenField ID="hdnId" runat="server" />
<div class="div_left">
<table>
<tr>
<td>
<div class="rotated_img_container_S">
<div class="rotated_img_S">
<img src="../Images1/cb.jpg" class="img_size_small" alt="" />
</div>
</div>
</td>
<td colspan="2">
<table>
<tr>
<td>
<a href="#" class="Links">
<%# Eval("UserName")%></a>
</td>
</tr>
<tr>
<td>
Shared with
</td>
<td>
<%# Eval("Posted_On") %>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="3">
<span>
<%#Eval("Post_Content")%></span>
</td>
</tr>
<tr>
<td>
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/Images1/lyk.png" CssClass="img_container" />
</td>
<td>
<asp:ImageButton ID="ImageButton2" runat="server" ImageUrl="~/Images1/share1.jpg"
CssClass="img_container" />
</td>
<td>
<asp:Button ID="btnComment" runat="server" Text="Comment" CommandName="Comment" CommandArgument='<%#Eval("Post_Id") %>'
CssClass="commentbox" />
</td>
</tr>
<tr>
<td colspan="3">
<uc1:CommentBox ID="CommentrBox1" runat="server" />
</td>
</tr><tr><td><asp:HiddenField ID="hdnId1" runat="server" value='<%# Eval("Post_Id") %>' /></td></tr>
</table>
</div>
</ItemTemplate>
<AlternatingItemTemplate>
<div class="div_right">
<table>
<tr>
<td>
<div class="rotated_img_container_S">
<div class="rotated_img_S">
<img src="../Images1/cb.jpg" class="img_size_small" alt="" />
</div>
</div>
</td>
<td colspan="2">
<table>
<tr>
<td>
<a href="#" class="Links">
<%# Eval("UserName")%></a>
</td>
</tr>
<tr>
<td>
Shared with
</td>
<td>
<%# Eval("Posted_On")%>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="3">
<div>
<%# Eval("Post_Content")%></div>
</td>
</tr>
<tr>
<td>
<asp:ImageButton ID="ImageButton3" runat="server" ImageUrl="~/Images1/lyk.png" CssClass="img_container" />
</td>
<td>
<asp:ImageButton ID="ImageButton4" runat="server" ImageUrl="~/Images1/share1.jpg"
CssClass="img_container" />
</td>
<td>
<asp:Button ID="btnComment" runat="server" Text="Comment" CommandName="Comment" CommandArgument='<%#Eval("Post_Id") %>'
CssClass="commentbox" />
</td>
</tr>
<tr>
<td colspan="3">
<uc1:CommentBox ID="CommentrBox1" runat="server" />
</td>
</tr>
</table>
</div>
</AlternatingItemTemplate>
<FooterTemplate>
</FooterTemplate>
</asp:Repeater>
protected void RepLeft_ItemCommand(object source, RepeaterCommandEventArgs e)
{
if (e.CommandName == "Comment" || e.CommandName == "Post" || e.CommandName == "Cancel")
{
RepeaterItem item1 = e.Item;
if ((item1.ItemType == ListItemType.Item || item1.ItemType == ListItemType.AlternatingItem) &&
item1.FindControl("CommentrBox1") != null &&
item1.FindControl("CommentrBox1").FindControl("Panel1") != null &&
item1.FindControl("CommentrBox1").FindControl("Panel1") is Panel)
{
Panel panel = (Panel)item1.FindControl("CommentrBox1").FindControl("Panel1");
if (panel != null)
{
if (panel.Visible == true)
panel.Visible = false;
else
panel.Visible = true;
}
}
if (e.CommandName == "Post")
{
if (item1.FindControl("CommentrBox1").FindControl("Panel1").FindControl("txtComment") != null)
{
if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
{
TextBox txt = (TextBox)item1.FindControl("CommentrBox1").FindControl("Panel1").FindControl("txtcomments");
HiddenField hdn = (HiddenField)item1.FindControl("hdnId1");
int id = Convert.ToInt32(hdn.Value);
}
}
}
}