如何获取HyperLinkField列在gridview中显示在单个单元格中的文本

解决方案 »

  1.   

    protected void gvData_RowCommand(object sender, GridViewCommandEventArgs e)
            {
                if (e.CommandName == "MyCommand")
                {
                    Button button = (Button)e.CommandSource;
                    GridViewRow row = (GridViewRow)button.Parent.Parent;
                    string a = row.Cells[1].Text.ToString();//获得第一个单元格的值   
                    string b = this.gvData.DataKeys[row.DataItemIndex].Values[0].ToString();//获得DataKeys的值   
                }
            }
      

  2.   

    ((HyperLink)GridView1.Rows[0].Cells[1].Controls[0]).Text 
      

  3.   

    二楼获取的是第一行吧 ,再加一个循环.....   用findcontrol也可以
      

  4.   

    搞定了,先将HyperLinkField转换为模板,再((HyperLink)GridView1.Rows[i].FindControl("HyperLink1")).Text