本文介绍了动态数据网格按钮两次单击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
请使用编辑按钮帮助有关动态数据网格.
单击保存/取消按钮后,它需要单击两次才能触发编辑命令.
下面是我制作动态数据网格和调用编辑命令功能的代码:
Hello everyone,
Please help regarding dynamic datagrid with edit button.
It needs to click twice before it trigger the edit command after clicking save/cancel button.
Below is my codes of making dynamic datagrid and calling edit command function:
Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
Dim grdCmpl As New DataGrid
With grdCmpl
.ID = "grid_" & compid
.AllowPaging = "false"
.CssClass = "InputText"
.HeaderStyle.CssClass = "DataGridHeader4"
.CellPadding = 0
.Width = 800
End With
AddHandler grdCmpl.ItemDataBound, AddressOf Item_Bound
AddHandler grdCmpl.EditCommand, AddressOf Edit_Command
End Sub
Sub Item_Bound(ByVal sender As Object, ByVal e As DataGridItemEventArgs)
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Or e.Item.ItemType = ListItemType.SelectedItem Then
Dim imgButton As New ImageButton()
With imgButton
.ImageUrl = "~/images/edit.gif"
.CommandName = "Edit"
.Attributes.Add("runat", "server")
.AlternateText = "Edit"
.ID = "imgbtn_" & e.Item.Cells(0).ClientID.ToString
End With
e.Item.Cells(e.Item.Cells.Count - 1).Controls.Add(imgButton)
End If
End Sub
在此先感谢
jyn
Thanks in advance
jyn
推荐答案
这篇关于动态数据网格按钮两次单击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!