您的位置:程序门 -> .net技术 -> asp.net



datagrid_itemcommand不执行


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


datagrid_itemcommand不执行
发表于:2007-08-24 17:31:38 楼主
datagrid_itemcommand不执行不知道是什么原因.
发表于:2007-08-24 17:32:151楼 得分:0
你不说说你怎么做的   ?
发表于:2007-08-24 17:36:362楼 得分:0
<asp:datagrid   id= "dgcorlist "   runat= "server "   cssclass= "table-shangxia "   autogeneratecolumns= "false "
width= "100% "   allowpaging= "true ">
<headerstyle   horizontalalign= "center "   backcolor= "#f1f1f1 "> </headerstyle>
<columns>
<asp:templatecolumn   headertext= "商品编号 ">
<itemstyle   horizontalalign= "center "> </itemstyle>
<itemtemplate>
<asp:label   runat= "server "   id= "lblproductnum1 "> </asp:label>
</itemtemplate>
</asp:templatecolumn>
<asp:templatecolumn   headertext= "折扣价格 ">
<itemstyle   horizontalalign= "center "> </itemstyle>
<itemtemplate>
<asp:textbox   id= "txtitempreferentialprice "   runat= "server "   width= "40px "   cssclass= "wenbenkuang "> </asp:textbox>
<asp:requiredfieldvalidator   id= "requiredfieldvalidator6 "   runat= "server "   display= "dynamic "   errormessage= "请输入特惠价格 "
controltovalidate= "txtitempreferentialprice "> </asp:requiredfieldvalidator>
</itemtemplate>
</asp:templatecolumn>
<asp:templatecolumn   headertext= "启用时间 ">
<itemstyle   horizontalalign= "center "> </itemstyle>
<itemtemplate>
<asp:textbox   id= "txtitempreferentialstart "   runat= "server "   width= "120px "   cssclass= "wenbenkuang "> </asp:textbox>
<asp:requiredfieldvalidator   id= "requiredfieldvalidator1 "   runat= "server "   display= "dynamic "   errormessage= "请输入时间 "
controltovalidate= "txtitempreferentialstart "> </asp:requiredfieldvalidator>
</itemtemplate>
</asp:templatecolumn>
<asp:templatecolumn   headertext= "截止时间 ">
<itemstyle   horizontalalign= "center "> </itemstyle>
<itemtemplate>
<asp:textbox   id= "txtitempreferentialend "   runat= "server "   width= "120px "   cssclass= "wenbenkuang "> </asp:textbox>
<asp:requiredfieldvalidator   id= "requiredfieldvalidator5 "   runat= "server "   display= "dynamic "   errormessage= "请输入时间 "
controltovalidate= "txtitempreferentialend "> </asp:requiredfieldvalidator>
</itemtemplate>
</asp:templatecolumn>
<asp:templatecolumn   headertext= "操作 ">
<itemstyle   horizontalalign= "center "> </itemstyle>
<itemtemplate>
<asp:button   id= "btupdate "   text= "更新 "   cssclass= "go-wenbenkuang "   commandname= "update "   runat= "server "> </asp:button>
<asp:button   id= "btdelete "   text= "删除 "   cssclass= "go-wenbenkuang "   commandname= "delete "   runat= "server "> </asp:button>
</itemtemplate>
</asp:templatecolumn>
<asp:templatecolumn   visible= "false "   headertext= "id ">
<itemtemplate>
<asp:label   runat= "server "   id= "saleid "> </asp:label>
</itemtemplate>
</asp:templatecolumn>
</columns>
<pagerstyle   nextpagetext= "下一页 "   prevpagetext= "上一页 "   horizontalalign= "center "   mode= "numericpages "> </pagerstyle>
</asp:datagrid>
发表于:2007-08-24 17:37:343楼 得分:0
我是通过datagrid_itemcommand去执行更新,删除的.
发表于:2007-08-24 17:40:324楼 得分:0
没看到你定义itemcommand事件
发表于:2007-08-24 17:45:465楼 得分:0
private   void   dgcorlist_itemcommand(object   source,   system.web.ui.webcontrols.datagridcommandeventargs   e)
{
if(e.commandname== "update ")
{
label   saleid=(label)e.item.findcontrol( "saleid ");
textbox   txtitempreferentialprice=(textbox)e.item.findcontrol( "txtitempreferentialprice ");
textbox   txtitempreferentialstart=(textbox)e.item.findcontrol( "txtitempreferentialstart ");
textbox   txtitempreferentialend=(textbox)e.item.findcontrol( "txtitempreferentialend ");
int   aa=int.parse(saleid.text);
sales   ss=new   sales();
ss.saleid=aa;
ss.saleprice=float.parse(txtitempreferentialprice.text);
ss.starttime=res.getdatetime(txtitempreferentialstart.text,datetime.now);
ss.endtime=res.getdatetime(txtitempreferentialend.text,datetime.now);
servicelocator.productservice.updatesalesprice(ss);
databind();
}
else
{
label   saleid=(label)e.item.findcontrol( "saleid ");
int   aa=int.parse(saleid.text);
servicelocator.productservice.deletesalesprice(aa);
databind();
}
}
发表于:2007-08-24 17:46:246楼 得分:0
this.dgcorlist.itemcommand   +=   new   system.web.ui.webcontrols.datagridcommandeventhandler(this.dgcorlist_itemcommand);
发表于:2007-08-24 17:48:077楼 得分:0
更新删除datagrid都提供了相应的事件!
deletecommand,updatecommand
发表于:2007-08-24 17:48:408楼 得分:0
看到了吧!不知道为什么它不执行.
发表于:2007-08-24 17:51:099楼 得分:0
1   确保   autoeventwireup= "false "  

2   设置一个断点看是否真的没有执行


快速检索

最新资讯
热门点击