隐藏自动生成的GridView列一个模板列 [英] Hide column of an autogenerated gridview with one templatefield

查看:210
本文介绍了隐藏自动生成的GridView列一个模板列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里自动生成列从visitid等。然而第一列是一个TemplateField。现在我想躲VisitID。我想这code,但没有奏效。我使用VB作为我的codebehind

I have autogenerated columns here from visitid and so on. The first column however was a templatefield. now I wanted to hide VisitID. I tried this code but it didn't work. I am using vb as my codebehind

e.Row.Cells(1).Visible = False

推荐答案

我尝试了好几种方法,但也与此code端和它的工作最后我只是增加了一个条件。对不起,也许我缺少的信息。我曾在GridView一个分页。这里是我的工作code。

I have tried several ways but also ended with this code and it worked finally I just added a condition. I'm sorry maybe I lacked information. I had a pagination in the gridview.. Here was my working code.

Protected Sub Gdvisitor_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles Gdvisitor.RowCreated
    If (e.Row.Cells.Count > 1) Then
        e.Row.Cells(1).Visible = False
    End If
End Sub

起初它是...... cells.count℃的,而没有工作指数仍超出范围,但是当我把它改为1。它的工作。我觉得分页有什么用它做。我不知道,但...谢谢所有帮助

At first it was "....cells.count < 0" and that didn't work the index was still out of range but when I changed it to 1. It worked. I think the pagination has something to do with it. I'm not sure though... Thank you for all the help

这篇关于隐藏自动生成的GridView列一个模板列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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