How i add New row to gridview when i click Add button


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 button

12/22/2008 12:43:24 PM 72751 articles. 3 followers. Follow

2 Replies

Similar Articles

[PageSpeed] 25



Thanks and Regards

Do remember to "Mark as answer" for this post or the post that helped you solve the issue
12/22/2008 12:50:50 PM

Hi adilahmedmd,

Agree with previous answer . We can utilize GV's foottemplate to implement inserting fucntion .

But usually , we use FormView or DetailsView control for inserting new record instead .
But here  How i add New row to gridview when i click Add button

So after you click the Add button , the new record has been added into db , what you need to do is to rebind GV . You just need to retrieve GV's datasource again and bind it to GV and invoke GV.DataBind() method.


Samu Zhang
Microsoft Online Community Support

Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question.
12/25/2008 3:21:57 AM

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 ...

Add a button to add a new row and insert the new record to gridview
Hello, 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 functio...

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...

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...

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....

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.&...

Getting an error to add a new row when a button is clicked inside a gridview
Here is the source code default.aspx <%@ Page Language="C#" AutoEventWireup="true" CodeFile="dgnewrow.aspx.cs" Inherits="dgnewrow" enableEventValidation="True"%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""> <html xmlns="" > <head runat="server"><title>Untitled Page</title> </head> <body> <form id="form1" runat="server">...

Urgent:How to Add Row with Control(RadioButton or CheckBox) to GridView in button Click
 Hi all,I have a DropDown in Page having values "Single" and "Multiple" .And one button outsidethe gridView.When i click on button should add one row to Gridview with RadioButton if DropDown selected is "Single"or CheckBox if  DropDown selected is "Multiple". How to Achieve this, help me urgent  Plz.From Ravi.    hiplease go here.Hope this wil help you  Warm Regards.Please don't forget to click "Mark as Answer" on the post that helped you....

does anyone know how to do that, when I click the last row of the gridview, the gridview will automatically add an empty new row for me.
does anyone know how to do that, when I click the last row of the gridview, the gridview will automatically add an empty new row for me.   thanks hi there,the only I could think of for now is is enbale footer rowthen hide it onpageload so when last row click set footer.visible to true  ...

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...

Add a row to table Dynamically for each click of Add Button
Dear All, I need to add one row to the existing table each time when I click Add button. I tried with the below code. It adds one row for the first click and for the next clicks it does nothing.. could you please recify where I am wrong? private void Button1_Click(object sender, System.EventArgs e){     int cnt = Convert.ToInt32(Session[COUNT]) + 1;    HtmlTableRow tRow1 = new HtmlTableRow();tRow1.ID = "rowID" + cnt;tblCR.Rows.Add(tRow1);HtmlTableCell tCel1 = new HtmlTableCell();tCel1.InnerText  = "aaa";tRow1.Cells....

Add rows to GridView on Button Click Event
Hai All, I have one gridview control and some textboxes are placed inside the update panel in my form. What I want is If I click the button (Add) the value of the textboxes are added to the gridview. How do i implement this? For example , Textbox1 = 'Value1', Textbox2 = 'Value2', Textbox3 = 'Value3', Textbox4 = 'Value4'. This four values are added to the gridview. Hi,I haven't tried it yet but i think this would do the trick, Try it this way            DataTable dt = new DataTable();...

how to add new blank row in table on button click
hi, can someone help me, i have problem to insert a new blank row in table on button click. i tried many links that show how to add row in table using database but it's not working. i don't want to use database. my situation is simple. i have table with 2 columns. everytime user want to add data, user will click "insert" button & new row will be added. then user will add data to the table. i dont want to retrieve any data from database or insert data to database. please help. tQ This has a sample:

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...

Web resources about - How i add New row to gridview when i click Add button -

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/1/2015 12:35:31 PM