Important alert: (current site time 7/16/2013 10:08:30 AM EDT)
 

winzip icon

ASP.NET Datagrid using SQL 2000

Email
Submitted on: 5/6/2002 11:26:53 PM
By: Daniel Hynes 
Level: Intermediate
User Rating: By 28 Users
Compatibility: VB.NET, ASP.NET
Views: 40284
 
     This ocde is meant to show how to use a datagrid in ASP.NET. It includes sorting, paging, editing, and a link to a detail form. I also made a simple user control and utilized the web.config to store the connection string. Please read the README file included in the zip. I hope this helps some people out. Please vote:-)

 
winzip iconDownload code

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. Afterdownloading it, you will need a program like Winzip to decompress it.Virus note:All files are scanned once-a-day by Planet Source Code for viruses, but new viruses come out every day, so no prevention program can catch 100% of them. For your own safety, please:
  1. Re-scan downloaded files using your personal virus checker before using it.
  2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.

If you don't have a virus scanner, you can get one at many places on the net including:McAfee.com

 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.


Other 2 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments
6/6/2002 11:44:47 AMHelena

Thanks a lot for your code. I was kinda lost with this new datagrid control, and it helped me to figure it out :-)
(If this comment was disrespectful, please report it.)

 
6/11/2002 2:42:32 AMDave

Excellant example of good code!
Good stuff
(If this comment was disrespectful, please report it.)

 
7/12/2002 10:57:16 AMMarco

Good work! made it look very simple, and very helpful.
(If this comment was disrespectful, please report it.)

 
8/10/2002 3:38:47 AMah king

very good for beginner! great work
(If this comment was disrespectful, please report it.)

 
11/4/2002 3:16:59 PM

Good Stuff! Very Helpful!
(If this comment was disrespectful, please report it.)

 
12/13/2002 1:18:24 PM

I was looking for a way to put the 'code behind' and all the examples I could find were not, THANKS for this clear example of datagrid editing with code behind.
(If this comment was disrespectful, please report it.)

 
3/3/2003 12:03:27 PMMike MacDonald

Thanks for posting. Been doing ASP and VB for a while, and now trying to pickup .NET. Your submission is a nice sample to learn from - thanks.
(If this comment was disrespectful, please report it.)

 
4/10/2003 4:24:46 AM

I'm in the middle of creating the same sort of thing, but I have a problem, the edit button works fine the textbox's appear ok but when I click update the values retuened is the data before I edited it. So for example I have a col with the name Ian, I edit it to John, click update and it returns Ian.

Can you help please.
(If this comment was disrespectful, please report it.)

 
4/10/2003 5:00:17 PMDaniel Hynes

In the example you will see the function GridUpdate. In there you can see where I update the name. For Example.
Do this first
Dim txtFirstName As TextBox
and set txtFirstName like below
'Set the Firstname equal to the second control in the Third Column (which would be the FirstName Textbox in edit mode
txtFirstName = e.Item.Cells(3).Controls(1)

Then when you run your update command you can send txtFirstName.Text as a Parameter Value

I am only going by the description you gave, but it could be possible that you are sending e.Item.Cells(3).Controls(0)
That would be sending the label in instead of the actual textbox value at the time. Please be sure that you are accessing the right control on the datagrid. It took me a while it get used to it too :-)
(If this comment was disrespectful, please report it.)

 
8/4/2003 6:42:56 AMS. Raghavendra

Thanks a lot. Looking for similar kind of functionality.
(If this comment was disrespectful, please report it.)

 
8/5/2003 3:33:06 AM

nice !
(If this comment was disrespectful, please report it.)

 
1/15/2004 11:42:33 AMJosé Alberca

Good stuff!
(If this comment was disrespectful, please report it.)

 
2/24/2004 9:04:24 AM

Great Work
(If this comment was disrespectful, please report it.)

 
2/24/2004 9:07:20 AM

Is that a sortable and pageable datagrid?
If I'll browse to another page would it remain sorted?
(If this comment was disrespectful, please report it.)

 
2/28/2004 11:47:15 AMDaniel Hynes

Yes, when you page the datagrid, it will keep the sort order. It will not if you navigate to another Webform.
(If this comment was disrespectful, please report it.)

 
3/3/2004 12:23:06 PM

Very good is a nice sample thanks.

(If this comment was disrespectful, please report it.)

 
7/19/2004 6:01:05 AM

Hi!
I m novice to this technology.Can u please brief me about wht is AssemblyInfo.vb... and other file like apsx.resx.I thought ther may be some mdb file as a database.
awaiting for ur kind help
(If this comment was disrespectful, please report it.)

 
9/1/2004 12:43:02 PMsebastian wolter

I cannot open the slution it says that the file northwindapplication.vbproj is not installed.
Why is that?
(If this comment was disrespectful, please report it.)

 
11/22/2004 12:45:00 PM

This is very good .. thanks
(If this comment was disrespectful, please report it.)

 
1/25/2006 5:28:01 PMTallion

Worked great for me! 5 stars!
(If this comment was disrespectful, please report it.)

 
3/24/2006 3:18:42 AMbinh filth

nice sample . thanks so much
(If this comment was disrespectful, please report it.)

 
5/8/2008 2:36:25 AMsantosh

but its great, for all even if its not good atleast ur doing something.really its very good job all ur doing.
(If this comment was disrespectful, please report it.)

 
6/28/2008 12:27:59 AMR1

it's Greattttt....
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.