隐藏以编程方式创建的gridview中的特定列

问题描述:

美好的一天!

我在想要隐藏特定列(例如column(0))的gridview中创建的gridview中创建了一个层次化的gridview.我无法实现.谁能帮我?

这是我的代码

Good day!

I created a hierarchal gridview in the gridview created inside a the gridview i wanted to hide a specific column say column(0). I could not make it happen. Can anyone help me?

here is my code

Protected Sub Gridview1_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) 
        If e.CommandName = "Expand" Then
            Dim gv As GridView = sender
                          
            con.Open()
            
                Dim ds As New DataSet
                Dim sql As String
                sql = "SELECT * From [someTable]"
                Dim adp As New SqlDataAdapter(Sql, con)
                adp.Fill(ds,"tblData")
                gv.Rows(rowindex).Cells(5).Controls.Add(gdv)
		'I tried this codes to hide the first column but nothing happens
		ds.tables("tblData").Columns(0).ColumnMapping=Data.MappingType.Hidden
		Dim gdv as New Gridview
                Dim gdv As New GridView
                gdv.DataSource = ds
                gdv.DataBind()
		gv.Rows(rowindex).Cells(5).Controls.Add(gdv)
End sub

我设法为遇到的问题创建解决方案;

这是解决方案.

I manage to create a solution to my on problem;

here is the solution.

Protected Sub Gridview1_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs)
        If e.CommandName = "Expand" Then
            Dim gv As GridView = sender

            con.Open()

                Dim ds As New DataSet
                Dim sql As String
                sql = "SELECT * From [someTable]"
                Dim adp As New SqlDataAdapter(Sql, con)
                adp.Fill(ds,"tblData")
                gv.Rows(rowindex).Cells(5).Controls.Add(gdv)
                Dim gdv As New GridView
                gdv.ID="GDV"
                gdv.DataSource = ds
                gdv.AutogenerateColumns=True
                AddHandler gdv.RowCreated, Addressof GDV_RowCreated
                gdv.DataBind()
                gv.Rows(rowindex).Cells(5).Controls.Add(gdv)
End sub

Protected Sub GDV_RowCreated(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
    e.Row.Cells(0).Visible=False
End sub


您可以编写代码在行中创建
You can write your code in row created
GridView1.Columns[0].Visible = false