TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Kavita Pharde
NA
44
79k
how to find id in repeater control
Aug 28 2013 7:22 AM
hi
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
<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>
.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);
}
}
}
}
Reply
Answers (
1
)
cannot implicitly convert system type to event handler
In page_load