在 gridview1 自定义模板列里面放了一个 linkbotton  id=linkbotton1  commandname=aa然后在gridview1  GridView.RowCommand 事件中  如何得到此行 主键(noteid)的值   ?谢谢 在线等中.........................

解决方案 »

  1.   

    if GridViewCommandEventArgs.CommandName=aa  thendim noteid as string'这里如何写
    Dim index As Integer=    ????????????????noteid=GridView1.DataKeys(index).Value.ToString()end if
      

  2.   

    int index = Convert.ToInt32(e.CommandArgument);
      

  3.   

    楼上的,我也用你的方方法,但是报错啊
    Input string was not in a correct format. 
    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.FormatException: Input string was not in a correct format.
      

  4.   

    int index = Convert.ToInt32(e.CommandArgument.ToString());
    就不会了
      

  5.   

    sorry报错的还是那一行  就是给index赋值的那一行  郁闷了ing
    在线等待中......
      

  6.   

    在 ItemDataBound 事件里
    你用: DataView1.DataKeys[e.Item.Index] 可以取得主键值,
    你想取那一行的主键值,利用DataKeys[当前行的索引] 就可以取到
      

  7.   

    还有一点你要给DataView1的属性 DataFieldKeys属性指定为 你当前绑定到此控件的表格的主键名,就是表中的主键字段名
      

  8.   

    楼上的不行啊我用的是gridview  继续等待...