int i = Convert.ToInt32(DataGrid1.DataKeys[0]);  这行代码只能显示 第一行的内容,我想定义一个变量,代替里面0,这个变量传递的是选中行的index。帮帮忙!!!

解决方案 »

  1.   

    在imagebutton的click事件中判断是datagrid哪一行的imagebutton发出的,然后取出这行的信息并传到新页面
    for(int i=0;i<this.Datagrid.Items.Count;i++) 
    {
    if (sender.Equals((imagebutton)Datagrid.Items[i].FindControl("imagebutton1")))
    {

    //取Datagrid中的数据

    } break;

    }
      

  2.   

    不是按钮,如果是的话,就好解决了,是添加了一个imagebutton.....