我在gridview中加了一个BoundField按扭,点击是弹出小窗口输入借书人信息,下面可以打开窗口,但不能获取ID号,查了很久都没有搞定,望指点 protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        string ID = this.GridView1.Rows[rowindex].Cells[0].Text.ToString();
        string jsText = "window.open('BorrInf.aspx?ID=" + ID + "','FS_Left','width=400,height=280,left=350,top=240')";
        ClientScript.RegisterStartupScript(GetType(), "newWindow", jsText, true);
    }

解决方案 »

  1.   

    <ItemTemplate>
      <a href='<%# "javascript:window.open(\"a.aspx?ID=" + Eval("ID")+ "\",null,\"width=300,height=200\");void 0;" %>'><%# Eval("Name")%></a>
     </ItemTemplate>
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)  
      {  
    if(e.CommandName == "")  
    {  
    string id = GridView1.DataKeys[Convert.ToInt32(e.CommandArgument)].Value.ToString();
    string script = string.Format("window.open('Default2.aspx?id_1={0}');",id );
    ClientScript.RegisterStartupScript(GetType(), "open", script, true);
    }  
      

  2.   

    谢谢一楼的,我用另外一种方法解决了。
    int index = Convert.ToInt32(e.CommandArgument);
            DataKey key = this.GridView1.DataKeys[index ];
            int tt = Convert.ToInt32(key.Value.ToString());
      

  3.   

    http://dotnet.aspx.cc/file/Add-Delete-Update-Edit-Data-With-Paging-in-GridView.aspx