in

C1 Community

ComponentOne Community is a free source for developers and help authors to collaborate and communicate.

Add new row to C1WebGrid

Last post 08-14-2008 4:29 AM by C1_SergeiS. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 08-10-2008 10:56 PM

    Add new row to C1WebGrid

    Hello,  

    I am trying to add new row into C1WebGrid, I am following on the help, but it's not working..

    to do SQLInsert, SQLUpdate, SQLDelete .. I use SQLDatasource  and its bound to C1WebGrid

    What I had:

    Private Sub C1WebGrid1_ItemCreated(ByVal sender As Object, ByVal e As C1.Web.C1WebGrid.C1ItemEventArgs) Handles C1WebGrid1.ItemCreated

    If e.Item.ItemType = C1.Web.C1WebGrid.C1ListItemType.Footer Then

    Dim btnAdd As New LinkButton()

    btnAdd.Text = "Add New"

    ' add a handler for the click event

    AddHandler btnAdd.Click, AddressOf AddNew_Click

    e.Item.Cells(0).Controls.Add(btnAdd)

    End If

    End Sub

    Public Sub AddNew_Click(ByVal sender As Object, ByVal e As EventArgs)

    Dim mSQL As String = "SELECT * FROM DIVISION"

    Dim mAdapter As OracleDataAdapter = New OracleDataAdapter(mSQL, ClsFunctions.GetConnectionString)

    Dim mDivision As DataSet = New DataSet

    mAdapter.Fill(mDivision, "Division")

    Dim table As DataTable = mDivision.Tables(0)

    Dim row As DataRow = table.NewRow()

    row.EndEdit()

    table.Rows.Add(row)

    Me.C1WebGrid1.EditItemIndex = table.Rows.Count - 1

    Me.C1WebGrid1.DataBind()

    End Sub

     

     

    Filed under: ,
  • 08-14-2008 4:29 AM In reply to

    Re: Add new row to C1WebGrid

    Check the attached sample.
     
    Regards,
    Sergey.

    Hello,  

    I am trying to add new row into C1WebGrid, I am following on the help, but it's not working..

    to do SQLInsert, SQLUpdate, SQLDelete .. I use SQLDatasource  and its bound to C1WebGrid

    What I had:

    Private Sub C1WebGrid1_ItemCreated(ByVal sender As Object, ByVal e As C1.Web.C1WebGrid.C1ItemEventArgs) Handles C1WebGrid1.ItemCreated

    If e.Item.ItemType = C1.Web.C1WebGrid.C1ListItemType.Footer Then

    Dim btnAdd As New LinkButton()

    btnAdd.Text = "Add New"

    ' add a handler for the click event

    AddHandler btnAdd.Click, AddressOf AddNew_Click

    e.Item.Cells(0).Controls.Add(btnAdd)

    End If

    End Sub

    Public Sub AddNew_Click(ByVal sender As Object, ByVal e As EventArgs)

    Dim mSQL As String = "SELECT * FROM DIVISION"

    Dim mAdapter As OracleDataAdapter = New OracleDataAdapter(mSQL, ClsFunctions.GetConnectionString)

    Dim mDivision As DataSet = New DataSet

    mAdapter.Fill(mDivision, "Division")

    Dim table As DataTable = mDivision.Tables(0)

    Dim row As DataRow = table.NewRow()

    row.EndEdit()

    table.Rows.Add(row)

    Me.C1WebGrid1.EditItemIndex = table.Rows.Count - 1

    Me.C1WebGrid1.DataBind()

    End Sub

     

     



    http://helpcentral.componentone.com/cs/forums/p/76143/207865.aspx#207865

Page 1 of 1 (2 items)
Contact ComponentOne: 1.800.858.2739 ©1987-2008 ComponentOne LLC All Rights Reserved.