How to add an Insert row to a GridView which is databound to a SQL server table?
-
I'm using C# ASP.NET 4 (VS2010) to create a database driven aspx file (SQL SERVER 2008 R2). My aspx file containing a GridView which allows me to edit and delete rows from the SQL server's table. I would like to add an insert row at the bottom of the Gridview, but I can't find the control for that, even after searching the internet for hours. When using Microsoft SQL Server Management studio there is a way to edit the top 200 rows of a table in a nice gridview, and there is an insert row at the bottom. My GridView is pure aspx with no code behind. I would like to imitate the that insertion row. This is how the edit (with the insert row) looks on Microsoft SQL Server Management studio: See at the picture above how I'm inserting the 3rd row of the table. See that there is a new row for insertion at the bottom of the gridview. Is it possible that there is no control for that with aspx gridview? If there isn't automatic insert row control, how do I do that with minimal C# code? With no solution, I thought of adding a button at under the GridView which will add a new empty row to the table. The problem is, my table do not allow nulls :)
-
Answer:
You'll need to make sure that you include an "InsertCommand" in your SqlDataSource and you'll need to do a little bit of work in the code-behind. To get a nice overview check out the article on this topic at the http://www.codeproject.com/Articles/18165/Using-the-Insert-feature-of-SqlDataSource-with-Gri
Different111222 at Stack Overflow Visit the source
Related Q & A:
- How to add primary key from multiple table as a foreign key in a table in sql server 2008?Best solution by stackoverflow.com
- How to add a new table to a data source?Best solution by technet.microsoft.com
- How to restrict access to a sql server database from Azure?Best solution by Stack Overflow
- How to present large dataset from a SQL Server query?Best solution by stackoverflow.com
- How to change column data's as a separate column wise format in a SQL Server?Best solution by stackoverflow.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.