Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 21st, 2005, 07:41 AM
Registered User
 
Join Date: Jan 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Adding a blank record to a grid (in edit-mode)

Hi..
I'm working with a custom collection of data (I've defined this collection as my own object) which gets filled with SQL-table-data using the:

> SQLhelper.ExecuteReader()

(I'm pointing this out, since alot of ppl seem to be using regular DataSets/DataViews, so my case is a little different than your mainstream DataGrid-issue ;) Not that I think I'm any better than everyone else, though )

Now, I want the user to be able to press a button (located below the datagrid) which then issues an SQL-command, which in turn creates an empty record in the table and finally (re)-binds the table-data to the datagrid. I have the above function(s) worked out, and it's working without a hitch.

My problem, however, is that I want to put this newly created empty record in edit-mode (right after the datagrid get's rebound).

In effect, the user will click the button and a new empty record (already in edit-mode) should appear at the bottom of the grid.

Any ideas will be highly appreciated..!
 
Old December 21st, 2005, 08:42 AM
Registered User
 
Join Date: Jan 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Eureka :D I found a solution.

I'm sorry if it seems as though I posted this problem, without first having tried to come up with a solution on my own. I can assure you that was not the case. I just happened to stumble upon the right tracks after having googled a bit more :)

To whom it may concern, here's my solution:
-------------------------------------------
#1) After having executed the SQL-command which adds an empty record to the table of choice -> bind the data to the grid

#2) Find the ItemIndex of the last item in the grid and enable EditItemIndex:

myDataGrid.EditItemIndex = myDataGrid.Items.Count.ToString() - 1

(I minussed 1 because the item-index is zero-based)

#3) Bind the data to the grid one more time.





Similar Threads
Thread Thread Starter Forum Replies Last Post
hiding grid edit mode msrnivas .NET Web Services 0 November 8th, 2004 04:59 AM
Datagrid - edit mode Programator ASP.NET 1.0 and 1.1 Professional 1 September 5th, 2003 08:38 AM
Datagrid - edit mode Programator ASP.NET 1.x and 2.0 Application Design 1 September 5th, 2003 08:37 AM
Datagrid - edit mode Programator Classic ASP Professional 0 September 5th, 2003 03:13 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.