我在第2页删除第2行,可是第1页的第2行被删除
i=e.item.ItemIndex
Dim DRow as DataRow
DRow=myDS.Tables(0).Rows(i)
Dim a1 as string=DRow("num").Trim()
Dim a2 as string=DRow("name").Trim()
我知道是i的问题,大家告诉我如何能解决啊,只要成功立刻给分,先来先给
i=e.item.ItemIndex
Dim DRow as DataRow
DRow=myDS.Tables(0).Rows(i)
Dim a1 as string=DRow("num").Trim()
Dim a2 as string=DRow("name").Trim()
我知道是i的问题,大家告诉我如何能解决啊,只要成功立刻给分,先来先给
DataKeyField="ID"
后台
DataGrid1.DataKeys[e.Item.ItemIndex]
i=datagrid1.DataKeys[e.Item.Itemindex]
Dim DRow as DataRow
DRow=myDS.Tables(0).Rows(i)
Dim a1 as string=DRow("yourname").Trim()
Dim a2 as string=DRow("yourkey").Trim()
我这么写出现错误
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message: BC30203: Identifier expected
出现错误
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: indexSource
i=datagrid1.DataKeys[e.Item.Itemindex]
Dim DRow as DataRow
DRow=myDS.Tables(0).Rows(i)
Dim a1 as string=DRow("yourname").Trim()
Dim a2 as string=DRow("yourkey").Trim()
我这么写出现错误你这么写有问题的,看你的这行代码:i=datagrid1.DataKeys[e.Item.Itemindex]
不能使用[]这个的!
出现错误
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
唉
这句放到DataKeyField="ID"前台中设定错误也是一样的
你使用断点看看
e.Item.ItemIndex
i=datagrid1.DataKeys(e.Item.ItemIndex)
这两个值是多少
DataGrid.DataSource = 求取到的数据集
DataGrid.DataKeyField = "xxx_id"
DataGrid.DataBind()
然后求取的时候才能使用DataKeys
dim i as string = DataGrid.DataKeys[e.Item.Itemindex].toString()