Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy onitemcommand of repeater control not working in this case?
    text
    copied!<p>I have Image in ItemTemplate that will be changing according to Username (ie lblPostedBy.Text). I have written code in onItemCommand of repeater control in C# Asp.net 4.0. But not working. Will you please help me.</p> <pre><code>protected void myrepeater_ItemCommand1(object source, RepeaterCommandEventArgs e) { // Actually lblPostedBy is a linkbutton and lblPostedBy.Text is 'username of the commenter'. LinkButton lblPostedBy = (LinkButton)e.Item.FindControl("lblPostedBy"); con.Open(); cmd.CommandText = "select image from " + lblPostedBy.Text + " where id=1"; // 'image' column in table stores path of image like '~/image/image1.jpg' cmd.Connection = con; string imageurl = (string)cmd.ExecuteScalar(); con.Close(); Image Image1 = (Image)e.Item.FindControl("Image1"); Image1.ImageUrl = imageurl; } </code></pre> <p>and</p> <pre><code>&lt;asp:Repeater ID="myrepeater" runat="server" onitemcommand="myrepeater_ItemCommand1"&gt; &lt;HeaderTemplate&gt; &lt;table width="100%" style="font: 8pt verdana"&gt; &lt;tr style="background-color:#3C78C3"&gt; &lt;th&gt;NEWS FEED&lt;/th&gt; &lt;/tr&gt; &lt;/HeaderTemplate&gt; &lt;ItemTemplate&gt; &lt;tr&gt; &lt;td valign="top"&gt; &lt;asp:Image ID="Image1" runat="server" Height="50px" Width="50px" /&gt; &lt;asp:LinkButton ID="lblPostedBy" runat="server" onclick="lblPostedBy_Click" Text='&lt;%#DataBinder.Eval(Container,"DataItem.postedby") %&gt;' /&gt; &amp;nbsp says : &lt;br /&gt; &lt;asp:TextBox id="txtPost" runat="server" Width="100%" textmode="multiline" text='&lt;%#DataBinder.Eval(Container,"DataItem.scraps")%&gt;' ReadOnly="True" BackColor="#EFF3FB" BorderStyle="None"&gt;&lt;/asp:TextBox&gt; &lt;%#DataBinder.Eval(Container,"DataItem.scraptime") %&gt; &lt;br /&gt; &lt;asp:TextBox ID="TextBox2" runat="server" Visible="False" Width="80%"&gt;&lt;/asp:TextBox&gt; &lt;asp:Button ID="btnDoneComment" runat="server" Text="Done" Visible="False" onclick="btnDoneComment_Click"/&gt; &lt;br /&gt; &lt;hr style="border:dashed 1px blue" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/ItemTemplate&gt; &lt;FooterTemplate&gt; &lt;/table&gt; &lt;/FooterTemplate&gt; &lt;/asp:Repeater&gt; </code></pre> <p>Thanks in Advance,</p> <p>Regards, Nikhil</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload