Click here to Skip to main content
15,897,371 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
<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]

C#
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);
                }
Posted
Comments
Thomas ktg 18-Sep-13 9:14am    
if (intRoleId == 1)
{
GridView1.Columns[5].Visible = false; //Change the index of the Cell to which the TemplateField resides
}
anurag19289 18-Sep-13 10:02am    
Thank you ... so the colum index starts from 0.
It's working :)

1 solution

C#
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
}
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900