在动态网格中将列的可见性设置为true [英] make visibility of a column to true in dynamic grid

查看:87
本文介绍了在动态网格中将列的可见性设置为true的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 <   asp:TemplateField     HeaderText   = 已批准Km By CTV   可见  =  false >  
< ; ItemTemplate >
< asp:TextBox ID = txtdistancectv MaxLeng th = 6 CssClass = textBox_for6tds runat = 服务器 > < / asp:TextBox >
< asp:RegularExpressionValidator ID = revtxtdistancectv runat = server 显示 = 静态

< span class =code-attribute> < span class =code-attribute> SetFocusOnError = True ValidationExpression = [0-9] * \。?[0-9] * ControlToValidate = txtdistancectv > < / asp:RegularExpressionValidator > < / ItemTemplate >
< ItemStyle Horizo​​ntalAlign = center / >
< / asp:TemplateField >









- 我必须做出决定e。如果introleid = 1,则网格的可见性为真。

- [它是网格的第4列]



< pre lang =cs> if (!Page.IsPostBack)
{
if (intRoleId == 1
{

// GridZeroApprovedKm.Levels [0] .Columns [4] .Visible = true;
}
ControlBinding.FillCombo(ddlhub, ASSOCIATED_HUBS,Session [TMS.Common.CommonConstants.CONST_COMPANY_ID] .ToString(),Session [TMS.Common.CommonConstants .CONST_USER_HUB_ID] .ToString(),Session [TMS.Common.CommonConstants.CONST_USER_ID] .ToString(), ,< span class =code-keyword> false );
}

解决方案

  for  int  i =  0 ; i< gridview1.rows.count-1; i ++)>  
{
if (RoleId == 1 // 给出您的条件
{
GridView1.rows [i] .cells [ 4 ]。Visible = true ; // 更改单元格[4]单元格[cellname]或更改索引
}
}


<asp:TemplateField HeaderText="Approved Km By CTV" Visible="false">
                           <ItemTemplate>
                               <asp:TextBox ID="txtdistancectv" MaxLength="6" CssClass="textBox_for6tds" runat="server">  </asp:TextBox>
                               <asp:RegularExpressionValidator ID="revtxtdistancectv" runat="server" Display="Static"

                                   SetFocusOnError="True" ValidationExpression="[0-9]*\.?[0-9]*" ControlToValidate="txtdistancectv"></asp:RegularExpressionValidator></ItemTemplate>
                           <ItemStyle HorizontalAlign="center" />
                       </asp:TemplateField>





--i have tomake the visibility of the grid to true in .cs if introleid=1
--[it is 4th column of the grid]

if (!Page.IsPostBack)
                {
                    if (intRoleId == 1)
                    {
                       
                        //GridZeroApprovedKm.Levels[0].Columns[4].Visible = true;
                    }
                    ControlBinding.FillCombo(ddlhub, "ASSOCIATED_HUBS", Session[TMS.Common.CommonConstants.CONST_COMPANY_ID].ToString(), Session[TMS.Common.CommonConstants.CONST_USER_HUB_ID].ToString(), Session[TMS.Common.CommonConstants.CONST_USER_ID].ToString(), "", "", "", false);
                }

解决方案

for(int i=0;i<gridview1.rows.count-1;i++)>
{
if (RoleId == 1)//give your condition
{
   GridView1.rows[i].cells[4].Visible = true; //Change the cell[4] Cell["cellname"] or change index
}
}


这篇关于在动态网格中将列的可见性设置为true的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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