How to add new row to datagrid?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Prasadsm
    New Member
    • Nov 2008
    • 14

    How to add new row to datagrid?

    Hi All,

    Check this....
    [code=vbnet]
    Public Sub CreateNewRow()
    Dim index As Integer
    index = StatusGrid.Item s.Count
    Dim da As New SqlDataAdapter
    conn.Open()

    da = New SqlDataAdapter( "select * from Status", conn)

    'New Row Creation
    da.Fill(dt)
    dt.Rows.Add(dt. NewRow)
    'dt.Rows.Insert At(dt.NewRow(), index)
    StatusGrid.Edit ItemIndex = index
    dt.AcceptChange s()
    StatusGrid.Data Source = dt
    StatusGrid.Data Bind()
    conn.Close()

    End Sub[/code]

    With this code, I got new row in the datagrid.

    But the problem Occurs, When the pagesize exceeds.

    Here I have given pagesize as 10.

    Assume there is 10 rows.Now When AddNewRow button is clicked, I should get new row in next page.(Total 11 rows).10 in first page and the new row in next page.

    How can I get this?

    Thanks in Advance...
    Last edited by Frinavale; Nov 5 '08, 03:25 PM. Reason: added [code] tags
  • nateraaaa
    Recognized Expert Contributor
    • May 2007
    • 664

    #2
    Please post your code that displays the properties you have set for the datagrid.

    Nathan

    Comment

    Working...