Click here to Skip to main content
15,895,784 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Right now my code below shows the column headers and row headers when loaded..However, when I bring the table up I want the table to be completely editable so that you can type in it. Any ideas of how to do that?

VB
Public Sub GetChartDataGrid()

        SqlChart.SelectCommand = "SELECT NAMES, vacAccrued, vacUsed, vacBalance, perAccrued" & _
                                 "FROM EMPLOYEES" & _
                                 "WHERE (NAMES = ?)'" & lblName.Text & "'"
        'Build your DataTable
        Dim dt As New DataTable()

        dt.Columns.Add(New DataColumn("Accrued", GetType(Integer)))
        dt.Columns.Add(New DataColumn("Used", GetType(Integer)))
        dt.Columns.Add(New DataColumn("Balance", GetType(Integer)))
        dt.Columns.Add(New DataColumn("Accrued ", GetType(Integer)))
        dt.Columns.Add(New DataColumn("Used ", GetType(Integer)))
        dt.Columns.Add(New DataColumn("Balance ", GetType(Integer)))
        dt.Columns.Add(New DataColumn("Total Balance", GetType(Integer)))
        dt.Columns.Add(New DataColumn("Sick", GetType(Integer)))
        dt.Columns.Add(New DataColumn("Other", GetType(Integer)))

        For j As Int16 = 1 To 13
            Dim dr As DataRow = dt.NewRow()
            For i As Int16 = 0 To 8
                dr(i) = 0
            Next i
            dt.Rows.Add(dr)
        Next j

        'Bind your data to a GridView
        GridViewChart.DataSource = dt
        GridViewChart.DataBind()

    End Sub

    Private Sub GridViewChart_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GridViewChart.RowDataBound

        Dim mons() As String = {"January", "February", "March", "April", "May", "June", "July", "August", "September",
                                "October", "November", "December", "Years Totals"}
        If e.Row.RowType = DataControlRowType.DataRow Then
            Dim lblRowHdr As Label = DirectCast(e.Row.FindControl("lblRowHdr"), Label)
            lblRowHdr.Text = mons(e.Row.RowIndex)
        End If

    End Sub
Posted

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