请问:DataGrid中如何添加“取消”按钮的客户端事件?

debugyong 2003-08-23 12:00:34
关于“编辑”和“更新”按钮,昨天我也提问过,感谢ericvan(骨灰虫)、panyee(快乐王子)、saucer(思归, .NET MVP) 各位老大的回答:http://expert.csdn.net/Expert/topic/2179/2179159.xml?temp=.3680689
现在我想对“取消”这个按钮添加一个客户端事件该如何做呢?同样在ItemDataBand事件中根本没法找到“取消”这个按钮,到底是怎么回事呢?
下面是在ItemDataBound中一个测试过程
if (e.Item.ItemIndex>=0)
{
for (int i=0;i<=e.Item.Cells.Count;i++)
{
try
{
for (int j=0;j<=e.Item.Cells[i].Controls.Count;j++)
{
object obj=e.Item.Cells[i].Controls[j];
string name=obj.GetType().ToString();
}
}
catch{}
}
}
我想通过上面的程序找到那个“取消”按钮来添加客户端事件
...全文
30 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
saucer 2003-08-23
  • 打赏
  • 举报
回复
sorry,

foreach (Control c in DataGrid1.Items[DataGrid1.EditItemIndex].Cells[n].Controls)
saucer 2003-08-23
  • 打赏
  • 举报
回复
in your EditCommand handler, after you bind the datagrid, try to find the buttons in DataGrid1.Items[DataGrid1.EditItemIndex].Cells[n] (n is the column where your buttons are):

foreach (Control c in DataGrid1.Items[DataGrid1.EditItemIndex].Cells[n])
{
if (c is Button)
;//....
}

see an example here
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=OmJL9otCDHA.1820%40TK2MSFTNGP12.phx.gbl
debugyong 2003-08-23
  • 打赏
  • 举报
回复
把“编辑”的按钮类型LinkButton改成PushButton,再按照思归老大的方法就行了,但如果不改类型的话还是找不到那个“取消”按钮。
caoit 2003-08-23
  • 打赏
  • 举报
回复
use Cancel

62,041

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧