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
i want particular id of user post i don't know to to get can anyone help me
thanks in advance
here is my code:
.aspx
onitemdatabound="RepLeft_ItemDataBound">
<%#Eval("Post_Content")%> | ||
CssClass="img_container" /> | CssClass="commentbox" /> | |
<%# Eval("Post_Content")%> | ||
CssClass="img_container" /> | CssClass="commentbox" /> | |
.aspx.cs
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);
}
}
}
}
1 Reply
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.

Iftikar HussainPosted Aug 28, 2013, 7:57 AM
You can get the id by reading CommandArgument like below
if (e.CommandName == "Comment" || e.CommandName == "Post" || e.CommandName == "Cancel")
string id=e.CommandArgument;
}
Regards,
Iftikar