请教删除datagrid当前行,急!!!
首先我讲数据集和datagrid绑定
然后添加一列[删除],用的是ButtonColumn
<asp:ButtonColumn Text= "删除 " DataTextField= "IndentID " HeaderText= "删除 " CommandName= "Delete " DataTextFormatString= "删除 "> </asp:ButtonColumn>
在此删除按扭的触发事件里删除此行
Private Sub DgMain_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DgMain.ItemCommand
With MyIndent
.Delete(DataGrid.DataKeys(e.Item.ItemIndex))
End With
End Sub
但是e.Item.ItemIndex取到的是当前的行号,我要取当前行的第一列的值
请大家帮忙!
[解决办法]
try:
Delete(DataGrid.DataKeys(e.Item.Cells[0].Text))
[解决办法]
显示当前行的第一列的值:
MsgBox(DataGrid1.Item(DataGrid1.CurrentRowIndex, 0).ToString)
------------------------------------------
我的书《Visual Basic .NET 2005数据库编程技术与实例》已由人民邮电出版社出版
人民邮电出版社出版:http://www.ptpress.com.cn/books/Book_Information.asp?BID=16271
中国互动出版网:http://www.china-pub.com/computers/common/info.asp?id=35208
------------------------------------------