gridview add / insert button

  • Thread starter Thread starter jobs
  • Start date Start date
J

jobs

I know native gridview does not support this and/insert of new rows..
what's killing me is I use to have this code that worked around this
but somehow I lost it. I recall suffering through it.

Would anybody have a sample of this in vb.net?

A simple gridview with line edit option an add button outside the
grid. When the add is selected a blank row with textboxes and dropdowns
at the top of grid allows for insert of a new row into the grid.

I have some notes, but can't seem to piece it together ...

Some clues from my notes:

Button puts gridview in edit mode.

GridViewRow newRow = GridView1.CreateRow(0, 0, 1, 2);
DataBind();

or

ds.Tables[ "Products" ].Rows.InsertAt( BlankRow, 0 );
and bind

to insert the blankrow at the top of the grid.



Kicking myself for having lost the code.

Thanks for any help, code or information!
 
something like this

Protected Sub AddButton_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles AddButton.Click

' A code to insert a new row to the database
...........................

' then...
DataGrid1.CurrentPageIndex = 0
DataGrid1.EditItemIndex = 0

' Load all rows again
LoadGridViewAgain()

End Sub
 
I'm working with Gridview under asp.net 2.0.

actually -1 t takes me out of edit mode.

= 0 causes me to go to edit mode on the top row.

I guess my question is, how can I add a blank row to the top of
gridview, not actually insert it into the data that that the grid is
bound to. this way in edit mode when I hit update, it will try to
insert whatever was keyed in. I use to have code to do this.
 
Back
Top