在datagrid中,添加了一个超级连接列(不是模板列),超级连接列邦顶了连接之后,用
Me.DataGrid1.Items.Item(0).Cells(1).Text 不能得到他的文本值,用这个都可以得到别的列的值,奇怪的是得不到这个超级连接列的值,难道非要我插入模板列,放入HyperLink这个控件后,用FindControl方法得到他的值吗?

解决方案 »

  1.   

    dim a as hyperlink=me.datagrid1.items.item(0).cells(1).findcontrol(0)
    a.text
      

  2.   

    超级链接列中不是值,而是一个hyperlink控件,所以取不到值....
    可以这样引用:HyperLink hl=(HyperLink)e.Item.Cells[index].Controls[0];
      

  3.   

    这个方法不行啊
     Dim a As HyperLink = Me.DataGrid1.Items.Item(0).Cells(1).FindControl(0)
            Me.Response.Write(a.Text)
    将对象引用设置到对象的实例。 
    说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。源错误: 
    行 46:     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    行 47:         Dim a As HyperLink = Me.DataGrid1.Items.Item(0).Cells(1).FindControl(0)
    行 48:         Me.Response.Write(a.Text)