1

我正在尝试以编程方式将复选框列添加到网格视图。这个网格视图有多个其他列,但我只希望复选框列是可编辑的。我见过的唯一示例要求我为每一行添加一个“编辑”链接。我希望复选框列默认可编辑,而不需要链接。该复选框还应支持自动回帖。有人有什么建议吗?以下是我到目前为止的内容:

    Dim gv As New GridView

    With gv
        .ID = "gridViewFoundUsers"
        .AutoGenerateColumns = False
        .DataKeyNames = New String() {"UserId"}
        .GridLines = GridLines.Both
        .AllowSorting = True
        .AllowPaging = True
        .PageSize = numRows
        .Width = tableWidth
        .BorderColor = Drawing.ColorTranslator.FromHtml("#808080")
        .AutoGenerateEditButton = True

        .HeaderStyle.CssClass = foundUserHeadStyle
        .RowStyle.CssClass = foundUserEvenRows
        .Columns.Clear()

        Dim UserIdTF As New BoundField
        With UserIdTF
            .DataField = "UserId"
            .HeaderText = "UserID"
            .SortExpression = "UserId"
            .ItemStyle.Wrap = True
            .ItemStyle.Width = 100
        End With

        Dim DomainTF As New BoundField
        With DomainTF
            .HeaderText = "Domain"
            .DataField = "Domain"
            .SortExpression = "Domain"
            .ItemStyle.Wrap = False
            .HeaderStyle.Font.Underline = False
        End With

        Dim SelectUserTF As New CheckBoxField
        With SelectUserTF
            .HeaderText = "Select User"
            .ItemStyle.Wrap = False
            .DataField = "isSelected"
        End With

        .Columns.Add(UserIdTF)
        .Columns.Add(DomainTF)            
        .Columns.Add(SelectUserTF)
     End With

gridview 是复合服务器控件的一部分,因此没有客户端代码页。

谢谢!

4

0 回答 0