Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert into GridView 1

Status
Not open for further replies.

bitseeker

Programmer
Nov 27, 2005
60
US
I'm designing an app for VB.Net VS 2005 ASP.NET in which users will review and add records to a list. To optimize the UI, I need to be able to insert records into the middle of the list. Ideally, there would be a control on one record that would say "insert a record below me". When the user activated that control, a "blank" record would appear below the record with the control, and the user would fill it in.

I recognize that there are lots of other ways to add records to a list, but this is the one that will be optimal in terms of how the user is reviewing and understanding the content.

It will look something like this:

1:
Seq# Content
1 AAAAAAA <Add Record after me>
2 BBBBBBB <Add Record after me> <=== click
3 CCCCCCC <Add Record after me>

2:
Seq# Content
1 AAAAAAA <Add Record after me>
2 BBBBBBB <Add Record after me>
3 <Add Record after me> <=== this appears
4 CCCCCCC <Add Record after me>

3:
Seq# Content
1 AAAAAAA <Add Record after me>
2 BBBBBBB <Add Record after me>
3 DDDDDDD <Add Record after me> <===user adds this
4 CCCCCCC <Add Record after me>

Hopefully, I can do this using GridView or similar as a base, rather than writing from scratch.
Any advice on a general approach to implementing this (including "write lots of custom code", if that's what it's going to take) would be appreciated.

Thanks!
 
I would use the details view to Insert a new row. The placement of the Insert is irrelavant since once you insert the row, the rows will be displayed in some order.

Jim
 
Thanks for input. This particular design is going to benefit from the particular "insert in place" that I described above, so I'm still looking for a way to do that.

One possible approach is to respond to the "click to add" event by adding a row to the Gridview datasource, and then refreshing the Gridview display...would that be headed in the right direction?
 
You would have to order the datasource some how to get the row where you want, and then automatically place the row into edit mode.
 
Thanks for the response. So let me play it back. 1) The SQL-like "insert" into a datasource adds a record to the datasource, but at the "end" (quote marks because I'm not sure sequential-ness actually applies). 2) And then, right, I would have to order the datasource so that the new record would appear in the right place, relative to the other records. That would work, because I've included the necessary columns to achieve that in the design. 3) And yes then, put the row into edit mode, so it can be changed.

OK. So what I'm getting is the design concept I would like to implement is possible within the basic Gridview framework. Sounds good! Please let me know if I've misunderstood anything. Thanks for the help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top