gridview add / insert button

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!
 
L

lexa

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
 
J

jobs

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top