本文介绍了如何使&lt; ASP:DataGrid列在其数据绑定时不可见?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 附加代码,但是给我一个错误的行是 MyDataGrid.Columns(2).Visible = False 它实际上给了我一个错误,而不是2,即使存在9个绑定的b / b $ b列数据。我如何隐藏列?谢谢。 MyConnection =新 SqlConnection(" server =(local); database = pubs; Truste d_Connection = yes") MyCommand = New SqlDataAdapter(" select * from Authors", MyConnection) DS =新数据集 MyCommand.Fill(DS,作者) MyDataGrid.DataSource = DS.Tables(" Authors")。DefaultView MyDataGrid.DataBind() MyDataGrid.BackColor = Color.White MyDataGrid.BorderColor = Color.Violet MyDataGrid.BorderStyle = BorderStyle.Dotted MyDataGrid.ToolTip =" JBs table" ''!!!!!!错误行 - 超出范围,但有9列。 MyDataGrid .Columns(2).Visible = False < ASP:DataGrid id =" MyDataGrid" RUNAT = QUOT;服务器" Width =" 700" BackColor =" #ccccff" BorderColor =" black" ShowFooter =" false" CELLPADDING = QUOT; 3英寸CELLSPACING = QUOT; 3英寸Font-Name =" Verdana" 字体大小=" 8pt" HeaderStyle-BackColor =" #aaaadd" EnableViewState =" false" /> 解决方案 Hi, Code attached but the line that gives me an error isMyDataGrid.Columns(2).Visible = FalseIt actually gives me an error for any value instead of 2 even when 9 boundcolumns of data exist. How do i hide a column? Thanks. MyConnection = NewSqlConnection("server=(local);database=pubs;Truste d_Connection=yes")MyCommand = New SqlDataAdapter("select * from Authors",MyConnection) DS = New DataSetMyCommand.Fill(DS, "Authors")MyDataGrid.DataSource = DS.Tables("Authors").DefaultViewMyDataGrid.DataBind()MyDataGrid.BackColor = Color.WhiteMyDataGrid.BorderColor = Color.VioletMyDataGrid.BorderStyle = BorderStyle.DottedMyDataGrid.ToolTip = "JBs table" ''!!!!!!Error line - out of range althought there are 9 columns.MyDataGrid.Columns(2).Visible = False<ASP:DataGrid id="MyDataGrid" runat="server" Width="700"BackColor="#ccccff" BorderColor="black"ShowFooter="false" CellPadding="3" CellSpacing="3" Font-Name="Verdana"Font-Size="8pt" HeaderStyle-BackColor="#aaaadd"EnableViewState="false" /> 解决方案 这篇关于如何使&lt; ASP:DataGrid列在其数据绑定时不可见?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-28 17:05