在DataList的图像按钮事件不工作 [英] Image button event in datalist not working
问题描述
图像按钮事件不会触发我失去了从我的code东西
上ItemCommand事件不会触发,请帮助我,我在这stucked
这是我的DataList code:
< ASP:DataList控件ID =DataList1=服务器RepeatColumns =1
RepeatDirection =垂直WIDTH =100%
onitemdatabound =DataList1_ItemDataBoundonitemcommand =DataList1_ItemCommand>
<&ItemTemplate中GT;
< DIV CLASS =comments_pannel_top>
< H2>强烈推荐,< / H>
< P>按:其中; A HREF =#>< ASP:标签ID =lblCustomerName=服务器>< / ASP:标签>< / A> -
< ASP:标签ID =lblCity=服务器>< / ASP:标签&gt ;,
< ASP:标签ID =原产国=服务器>< / ASP:标签> <跨度>
< ASP:标签ID =lblDate=服务器>< / ASP:标签>< / SPAN>< / P>
< / DIV>
< DIV CLASS =stars_1>
< IMG SRC =图像/ favourities_icon.jpgWIDTH =12高度=12ALT =/>
< IMG SRC =图像/ favourities_icon.jpgWIDTH =12高度=12ALT =/>
< IMG SRC =图像/ favourities_icon.jpgWIDTH =12高度=12ALT =/>
< IMG SRC =图像/ favourities_icon.jpgWIDTH =12高度=12ALT =/>
< IMG SRC =图像/ favourities_icon.jpgWIDTH =12高度=12ALT =/>
< / DIV>
< DIV CLASS =评论>
< P><强大于5的11人认为该评论有用< / STRONG>< / P>
&所述p为H.;
< ASP:标签ID =lblReview=服务器>< / ASP:标签>< / P>
< / DIV>
< DIV CLASS =report_abuse>
< P>你有没有发现这条点评< / P>
< / DIV> < DIV CLASS =comments_pannel_bottom>
< DIV CLASS =btns>
< ASP:ImageButton的ID =btnYes的ImageUrl =图片/ yes_btn.jpgWIDTH =33高度=23=服务器的CommandName =是/>
< ASP:ImageButton的ID =btnNo=服务器的ImageUrl =图片/ no_btn.jpgWIDTH =33高度=23ALT =的CommandName =否/> < / DIV>
< / DIV>
< / ItemTemplate中>
< / ASP:DataList控件> 这是onitem命令事件处理程序: 保护无效DataList1_ItemCommand(对象源,DataListCommandEventArgs E)
{ }
什么服务器端事件处理程序是他们必然?通常,标记包含绑定命令事件到服务器端处理程序的按需
属性。见的例子<一个href=\"http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.imagebutton.commandname.aspx\"相对=nofollow>这里:
&LT; ASP:ImageButton的ID =imagebutton2=服务器
还有AlternateText =编辑
的ImageUrl =图片/ pict2.jpg
按需=ImageButton_Command
的CommandName =编辑/&GT;
为按需
属性的值将是服务器端的事件处理程序方法的名称:
无效ImageButton_Command(对象发件人,CommandEventArgs E)
{
// ...
}
the image button events are not firing am i missing something from my code the on itemcommand event doesn't trigger please help me i'm stucked in it this is my datalist code:
<asp:DataList ID="DataList1" runat="server" RepeatColumns="1"
RepeatDirection="Vertical" Width="100%"
onitemdatabound="DataList1_ItemDataBound" onitemcommand="DataList1_ItemCommand">
<ItemTemplate>
<div class="comments_pannel_top">
<h2>Highly Recommended,</h2>
<p>By:<a href="#"><asp:Label ID="lblCustomerName" runat="server"></asp:Label></a> –
<asp:Label ID="lblCity" runat="server"></asp:Label>,
<asp:Label ID="lblCountry" runat="server"></asp:Label> <span>
<asp:Label ID="lblDate" runat="server"></asp:Label></span></p>
</div>
<div class="stars_1">
<img src="images/favourities_icon.jpg" width="12" height="12" alt="" />
<img src="images/favourities_icon.jpg" width="12" height="12" alt="" />
<img src="images/favourities_icon.jpg" width="12" height="12" alt="" />
<img src="images/favourities_icon.jpg" width="12" height="12" alt="" />
<img src="images/favourities_icon.jpg" width="12" height="12" alt="" />
</div>
<div class="comment">
<p><strong>5 out of 11 people found this review helpful.</strong></p>
<p>
<asp:Label ID="lblReview" runat="server"></asp:Label></p>
</div>
<div class="report_abuse">
<p>Did you find this review helpful?</p>
</div>
<div class="comments_pannel_bottom">
<div class="btns">
<asp:ImageButton ID="btnYes" ImageUrl="images/yes_btn.jpg" width="33" height="23" runat="server" CommandName="Yes" />
<asp:ImageButton ID="btnNo" runat="server" ImageUrl="images/no_btn.jpg" width="33" height="23" alt="" CommandName="No"/>
</div>
</div>
</ItemTemplate>
</asp:DataList>
This is the onitem command event handler:
protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
{
}
What server-side event handler are they bound to? Usually the markup contains an OnCommand
property which binds the command event to a server-side handler. See examples here:
<asp:ImageButton id="imagebutton2" runat="server"
AlternateText="Edit"
ImageUrl="images/pict2.jpg"
OnCommand="ImageButton_Command"
CommandName="Edit"/>
The value for the OnCommand
property would be the name of the server-side event handler method:
void ImageButton_Command(object sender, CommandEventArgs e)
{
//...
}
这篇关于在DataList的图像按钮事件不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!