当前位置: 代码迷 >> ASP.NET >> 如何把datagrid里的模版列里的的button的type修改掉
  详细解决方案

如何把datagrid里的模版列里的的button的type修改掉

热度:881   发布时间:2013-02-25 00:00:00.0
怎么把datagrid里的模版列里的的button的type修改掉?
1.模版列放webcontrol时,运行程序察看html代码发现为<input type=submit>,此时3正常。
2.模版列放Htmlcontrol时,运行程序察看html代码发现为<input type=button>此时3,4都不正常。报Specified cast is not valid.
3. ((Button)e.Item.Controls("btnCancel")).Visible = false;
4. ((HtmlButton)e.Item.Controls("btnCancel")).Visible = false;
现在我需要将button设置type=button,我哪里做的不对呢,有人知道吗?

------解决方案--------------------------------------------------------
没碰到过。加个RUNAT=SERVER
------解决方案--------------------------------------------------------
是你代码错了吧,
你要查询为什么不用服务控件
------解决方案--------------------------------------------------------

Htmlcontrol 控件要想在后台访问到在<input type=button>中,应该有runat = server 标记的,像这样
<input type=button runat = server >

------解决方案--------------------------------------------------------
Htmlcontrol控件没有Visible属性:
1.加 runat=server属性: <input type=button runat=server> 
2. ((HtmlButton)e.Item.Controls( "btnCancel ")).Attributes.Add("style","display:none");
  相关解决方案