Add a button to add a new row and insert the new record to gridview


I have a gridview1 on a page attached to a SQLDataSource.  The gridvioew page is displayed when a selection from a drop down box on the master page matches the FK field (partID) on the gridview page via querystring.  I would like to add a buttton that allows me to add a row to gridview1 without losing the information already displayed, typed in, or updated.  I have the PK and 8 check box feilds set as bound field (DetailID) and all of the remaining 10 text fields converted to template fields.  What is the best way to add this functionality?

Thank you,

2/25/2008 8:29:36 PM 72751 articles. 3 followers. Follow

5 Replies

Similar Articles

[PageSpeed] 25

The first part of this is easy enough the second part is how to add a row dynamically to the grid without loosing the data already there is easier done in code than using SqlDataSource.  I have already shown many times on this forum how to do this.  There is a bit of a trick. which creates the row and then adds it to the grid.  I do not know how to force the SqlDataSource to behave under this circumstance but I can show you a complete solution done with code instead if you are interested

I am not anti social, am just not user friendly
2/25/2008 11:04:21 PM

Yes I am interested

2/25/2008 11:30:28 PM

I resolved the problem using code like you said tied to the insert function.

3/1/2008 12:14:42 AM


I'm interested in a similar solution.  In Expression Web, I have a gridview tied to a SQLDataSouce.  Row Edit and Delete are already autogenerated via Tag Properties.  I still need to be able to allow users to add new row(s) to the grid.  Can you help?  Thanks!

3/14/2008 8:01:55 PM

I have a solution based where I have a gridview and added a footer to the gridview: My solution was based on the article listed below.  Read the article and build your page the same way if you can.  When you run into a problem, post your code  so I can see what is going on.


3/14/2008 9:32:35 PM

Similar Artilces:

Add new controls to a gridview row; when editing that row using the edit row feature in the gridview control.
Hi all  I have a questions that looks hard / complex to me, and i know you can help me in this. Q {  I have row in a Gridview and i have an edit option to it. I press the edit button, to edit the values in that row and update data all the way back to the database. Now when i press the edit button, i want a drop down list to be displayed that contain values for a particular field in my grid view. (for now only plain text boxes appear.) } I hope you understand my question, all i need to do is replace the text box controls with a dropdown list when i am editing a row in ...

How i add New row to gridview when i click Add button
Hi, I have Gridview control , it is populated from Products Table from my database ProductNo,ProductName, ProductPrice, PrductCategorytype I added Edit and delete buttons to Gridview. Here  according to my user requirement  , i shuld add ADD button outside Griedview contrl, for Inserting New records into database  when i click ADD button But here  How i add New row to gridview when i click Add buttonadilahmed  Thanks and RegardsS.K.Vignesh----------------------Do remember to "Mark as answe...

add new items then clicking on refresh button will add new duplicate records to database.
hi,  i have used commandfield for updating and inserting but after i insert one record and click on refresh duplicate record is added to database. thanks in advance Refresh will repeat the previous postback; so if you added a new record in the previous postback (on Inert click, may be?) then Refresh will add another record (duplicate).Mark replies as answers if they helped you solve the problem. i have used commandfield for updating and inserting but after i insert one record and click on refresh duplicate record is added to database. Check this http://blo...

Gridview does not display the new record after I click the Add button and the record is added to the DB.
HI  page: VS 2005 & I have an aspx page that has a Gridview control with the footer row enabled for the purpose of adding a blank row at the bottom of the gridview that is used to add new records to the db table.  I have a template field with the Add linkbutton control that is used by the end-user to click on when they finished inserting the new information they want added.  I placed an datasource control on the page that the Add buton uses to insert the new information below: Problem: When I click the Add button, the data is added to the DB but I have ...

Add new record or row in Gridview.
What is the best practice for adding a new record or a new row to Gridview?  In other words, I have seen example where people add blank row to an existing datagrid, enter the info and hit the SAVE button.  While other have a ADD NEW button and use a separate interface to add new information.  I'm looking for best practice and easy to implement.  I prefer not to write hundred line of codes to add a single record when I can click a button to do so.  Thanks. Hi, I think it is up to client requirements and how they want. You could put the insert function in...

how to add new record in gridview control
I am using gridview control in my application(ASP.NET 2.0). It is bind using SqlDatasource. I am using in-built functionality of gridview to Edit, Select and Delete records and it's working as per my requirements. But can anyone tell me how to add new record through gridview. Please reply urgent.     Please refer these links.GridView Operation "A conclusion is where you got tired of thinking.Be different. Think "Remember to click “Mark as Answer” on the post If you get answer from my post(s) !Thanks Guys------------Pushkar  You will find the followi...

Add new record to gridview control
I have several reference tables that I need to create web interfaces for.  I'm using the gridview control to display the list.  I've experimented with two approaches for the insert, 1) textboxes at the top of the form with an "Add" button to insert the new record, and 2) gridview tied to a detailsview control.  The problem with #2 is that you have to select an existing record from the list to get the detailsview control to display, then click add.  kind of messy for the user.  The first is more of the traditional approach, so I was wondering what other approaches are...

add new rows in gridview on button click
Hi , I am designing a gridview.In that i have a add button on the header and edit /update/cancel for all rows.If i click add button i have to insert new empty row( which has 2 textboxes,2 dropdownboxes=total 4 columns)  on the bottom of the gridview with no edit/update/cancel Can anyone let me know how to do this.I use rowcommand and find out command name and i am calling afunction   like <asp:gridview id="gridview1" onrowupdating ="row_update" onrowediting="row_edit" onrowcancelingedit="canceledit" onrowcommand="addemptyrow&q...

how to add new row & insert controls
Hi,  I have following fields, Projects ------> dropdown Task    -----> dropdown Totalhrs    ----> textbox Notes  ----> textbox i am displaying them in a table format...I have a button like "Add New Row". When user clicks it...I need to add a row to table with all above controls. How to achieve this...plz can anyone help me. All the above controls are web server controls. Thanks, Cute.  Thanks,Cute keep a hidden field to store how many ...

Add new row to a binded gridview on button clicked?
 Hi all,I have a GridView that binded to some data in SQL database. (see image) What I'm trying to accomplish is that when I click on the "Add Lot" button, a new row WITH THE EXACT COLUMNS of the clicked button is insert RIGHT BELOW that row. So for example, if I click the "Add Lot" button on the first row (with SKU 4942718), a new Row will be inserted right below it, with the exact same information (SKU, a textbox for LOT #, another column with a textbox / dropdownlist / add lot button.) I'm relative new to .net so any help would be greatly appreciated....

Adding a new row in the gridview on click of add button..
Hi, I have a gridview which gets populated by calling BLL method . My BLL returns Datatable and am binding it to the gridview.Now i want to add new row.For that i have written aspx as below:   <asp:GridView ID="gvSubContractor" runat="server" AutoGenerateColumns="False" EmptyDataText="No Data"Width="959px" ShowFooter="false" OnRowCreated="gvSubContractor_RowCreated" onrowcommand="gvSubContractor_RowCommand"> <RowStyle CssClass="ItemStyle" /> <Columns> <asp:TemplateField...

How to add a new row into gridview using Objectdatasource control
Hi, I am binding data into the gridview using objectdatasource control. I am able to perform the update and the delete functionality. But I need to insert a new row into the gridview and then somehow wire up the objectdatasource control to do the insert routine for me. I am using business logic layer plus the dataaccess layer along with stored procedures to achieve the above. Can some one tell me how to perform the insert routine? Hi guyind, It is no matter which datasource control you use, ObjectDataSource or SqlDataSource. You can set InsertMethod into ObjectDataSource to insert a new r...

Add new record then get unique id of new record
Hi: I have a .net 2.0 application that inserts a record into a database.  What I would like to do is: (1) Confirm the success or failure of the insert. (2) On success, get the unique ID of that new record so I can show it in a popup to confirm to the user as a Tracking Number. (3) On fail, note why and inform user. I am using VB code behind and a module call for all my database calls.    'Add new request to database Dim oSQL As New SQLDB("SERVER", "DATABASE", "USERID", "PASSWORD") oSQL.RunSQLAction("INSERT INTO DATABASE(PermitType, PM, PMPhone, Request...

How can we add a new row to the gridview in the button click event
I have a button,3 textboxes and a gridview.Iam adding the textboxes to the gridview and iam binding a datatable . Now my question is that how can i add a new row to my gridview in the button click event. in the button click event, if u update the datatable, the grid view should read/refresh  the new rows into the page. what are u thring to  do , you want to do this thorguh to UI . . if so what is the use of text boxes.  Sunil Okay that's not difficult but the consequences are. you may need to write a good deal of code to add row manange the user created row.&...

Web resources about - Add a button to add a new row and insert the new record to gridview -

GridView SelectedItem Binding Gotcha in WinRT
Last night when I was doing some WinRT hacking I was trying to setup databinding to the selected item in the GridView control and I ran into ...

CNW Group
Home Services Beyond the Wire About CNW Financials Webcasts Events My CNW All News Releases Advanced Search Gridview Latest News Releases All ...

CNW Group
... Services Beyond the Wire About CNW my CNW CNW Access CNW Directories Financials Webcasts Events my CNW All News Releases Advanced Search Gridview ...

CNW Group
Home Services Beyond the Wire About CNW Financials Webcasts Events My CNW All News Releases Add a Filter Gridview Latest News Releases All Today ...

New CmdLets of Powershell 2.0
New CmdLets of Powershell 2.0

Price Drop: Softbox
... objects- create product reflection- changing the background with something more interestingUse it as:- softbox- honeycomb softbox- gridview ...

Profile.aspx: ASP Alliance
.NET,ASP,ASP.NET,SQL,XML,HTML,ADO,ADO.NET,JavaScript,JScript,CSharp,VBScript and VB tutorials from AspAlliance.

Quick Answers - CodeProject
Questions - Free source code and tutorials for Software developers and Architects.; Updated: 25 Oct 2012 - Upcoming stories is a community based news site edited by our members. It specialises in .NET development techniques, technologies and tools including ...

View Features - ExtendASP
Call 847-681-9827 or Request a Demo View Features Testimonials Pricing About Us Coming Soon ExtendASP exposes every feature, more than any other ...

Resources last updated: 12/23/2015 1:31:19 AM