C
Chris Leuty
I have a datagrid (with viewstate enabled), and my edit/update/delete
buttons in the grid are all working fine. I have a textbox and a button
underneath the grid for adding items to the grid. When the button is
clicked, the following code runs:
Dim drNew As DataRow = dsTrades.Tables("Trades").NewRow ' create
new row
dsTrades.Tables("Trades").Rows.Add(drNew)
' add new row to table
drNew("TradeName") = Request.Form("txtNewTrade") '
get TradeName from post
daTrades.Update(dsTrades)
' update database
daTrades.Fill(dsTrades)
' re-load the sorted list...
dgTrades.DataBind()
' bind the grid
The item adds properly to the database, but the newly added item always
appears as the first row in the grid, if the grid is currently on the first
page, regardless of where it should appear (it is a sorted list). Calling
the grid page again fixes the problem (i.e. the item begins to show up in
the correct place). My basic question is: why doesn't the Fill() and
DataBind() when I am adding refresh the grid before rendering?
Thanks,
Chris
buttons in the grid are all working fine. I have a textbox and a button
underneath the grid for adding items to the grid. When the button is
clicked, the following code runs:
Dim drNew As DataRow = dsTrades.Tables("Trades").NewRow ' create
new row
dsTrades.Tables("Trades").Rows.Add(drNew)
' add new row to table
drNew("TradeName") = Request.Form("txtNewTrade") '
get TradeName from post
daTrades.Update(dsTrades)
' update database
daTrades.Fill(dsTrades)
' re-load the sorted list...
dgTrades.DataBind()
' bind the grid
The item adds properly to the database, but the newly added item always
appears as the first row in the grid, if the grid is currently on the first
page, regardless of where it should appear (it is a sorted list). Calling
the grid page again fixes the problem (i.e. the item begins to show up in
the correct place). My basic question is: why doesn't the Fill() and
DataBind() when I am adding refresh the grid before rendering?
Thanks,
Chris