隐藏以编程方式创建的gridview中的特定列 [英] Hide specific column in a gridview created programmatically

查看:94
本文介绍了隐藏以编程方式创建的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


这篇关于隐藏以编程方式创建的gridview中的特定列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆