Add new row at the footer issue

hi,

i got a datagrid and i want to add "Add new row" operation for it.
i noticed that everyone is suggesting to put the Insert link & edit boxes in the Footer and then just read the values from there and update the DB.
what if i want to have a Total cells in my Footer? this collide with the idea of having text boxes in my footer?
is there any other way to implement the "Add new row"?
two footers? a changing footer?
Anyone got any idea?
thanks in advance,
Avi.
0
Avi
11/17/2004 9:09:26 AM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

7 Replies
427 Views

Similar Articles

[PageSpeed] 42

Just put a button (or linkbutton) without any other controls in the most logical place - say right below the grid or above the grid On the click event add new records to the datasource of the grid but do not specify any values, show the grid with a newly added row in Edit mode. This way you will avoid using extra controls to specify the initial values.

Cheers
Bug [MCSD]
0
Bug_Bugger
11/17/2004 2:04:43 PM
i init the datagrid.DataSource with an ArrayList.

should i keep the ArrayList so i could do some changes to it (like add new rows)?
bcuz in the datagrid_ItemCommand(...)
the datagrid.datasource is null...
?
0
Avi
11/17/2004 5:28:04 PM
Well, if you want to store more than one item in your grid then you need to persist the ArrayList between requiests. Ideal place would be the Session variable.
Bug [MCSD]
0
Bug_Bugger
11/17/2004 5:42:53 PM
let me get this straight - 

you want me to store the list of data in the session and then in the dg_ItemCommand
do this -

private void dg_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
if (e.CommandName == "Insert")
{
ArrayList list = (ArrayList)Session["Products"];
if (list != null)
{
int i = list.Add(new Product());
dg.EditItemIndex = i;
BindData();
}
}
}

this doesn't do anything...
0
Avi
11/17/2004 8:16:10 PM
then again , this would work but my Paging will get me an exception


if (e.CommandName == "Insert")
{
ArrayList list = (ArrayList)Session["Products"];
if (list != null)
{
list.Insert(0,new Product());
dg.EditItemIndex = 0;
dg.DataSource = list;
dg.DataBind();
}
}

i read in some forum about BindingManagerBase, do u recommend it?
Avi.
0
Avi
11/17/2004 8:34:31 PM
What you have to do is split your logic into procedures in such a way that they will do only what they are meant to do on that logical context and make sure all the resources are available to those procedures to do the job. As i understand, you are always binding your DataGrid to the ArrayList. So, why don't you declare a class level variable to hold the reference to that ArrayList and make sure it is either loaded from the Session or created as new (if nothing yest is stored in the session variable) in the Load event of the page. This way, your ArrayList will be available to any code inside your class and you will be able to separate the databinding logic into its own procedure(BindData();) and paging will not be effected by the code in the ItemCommand event handler.

Cheers
Bug [MCSD]
0
Bug_Bugger
11/18/2004 8:37:22 AM
done, and it worked (as always with your instructions...)

thanks man! :)
0
Avi
11/18/2004 8:07:25 PM
Reply:

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 New Row To DataGrid Using the Footer With a DropDownList Control
I am trying to discover the best method for adding a new row of data to a datagrid. My datagrid is bound to an SQL Server table. I was reading the article "Adding a New Record to the Datagrid", by John Sanborn (4GuysFromRolla.com) wherein he suggests a method of using the datagrid's footer for adding new records. The concept works if each column of data is to be keyed in by the user, but I have a requirement to provide a drop-down list of valid values for a specific column. I've been tinkering with using a drop-down list in the footer of the grid, but I am unable get it to displ...

How to add a footer row to a table after deleting all footer rows
I'm sure this is a very easy thing to do, but I can't figure out how to do it. I have a table, and I deleted all the footer rows.  Now I would like to add one footer row.  How do I do that? If I right-click on the detail row and select Insert Row Below, it is, of course, another detail row. I'm stumped -- thanks for any help you can give!Cynthia Do you have groups in your table?  You should be able to right click on any table row and toggle the corresponding menu item to show the table header, details or footer.  It is in the right click menu includ...

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

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 http://www.denisbauer.com/ASPNETControls/DynamicControlsPlaceholder.aspx keep a hidden field to store how many ...

How to add new BLANK row in DataList control
Hi Friends, I am using DataList control to display items related to months in my Project using ASP.Net 1.1. There is a situation in which I have to add new blank row at the begining or end of every month. Say, for example, it's like a header for a particular month. Display a row with "January" as the text and below that row need to display items from 1st Jan to 31st Jan. This will repeat for each and every month. My Source code is as follow:HTML CODE:  1 <asp:datalist id="DataList1" style="LEFT: 0px; TOP: 32px" runat="server" Height=...

PB2.5: how to add a new row on DW and setfocus on specificated field of the new row.
I need to add a row on a datawindow when user press the 'tab' on the last field of the previous row. using dw_1.insertrow(0) in ItemChanged event does'nt work because the focus rest on the "old" line. Someone can tell me instructions to do this ? TIA roberto Roberto; The "tab" on the last field will fire the IC event if data has changed. If you are doing the InsertRow ( ) then, you are almost there in your problem. You may just need to tweak the UI as follows: DW Control IC event ... Long ll_row ll_row = InsertRow (0) ...

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

How to add new rows in the form of rows
Hi, I can able to insert,delete and update record in gridview but cannot able to insert any new rows in the gird. In windows application we can insert new records(using DataGridView) into the database but not in web page. How to insert the records in gridview like control. Please tell me how to insert records in database in the form of rows. I mean i want to enter 20 records at one time.   Thanks.   Regards ArshadPlease Mark as Answer if the post is helpful to you. hi, Have you set the property AllowUserToAddRows=True; for the datagridview?????  If you are us...

Add Blank Row to Datagrid Footer to Insert new records
Working with a datagrid with the following capabilities: - Edit - Dropdownlists to display parent data (foreign key) - Delete (with confirmation) This all works, thanks to some excellent code examples on the internet But, when I try to add a blank row to the footer, I’m experiencing all sorts of grief – I need a COMPLETE example for a datagrid that implements ALL this functionality (preferably in C#). Thanks for any help provided !!! Karen M. Sullivan Hai KSulli, refer the following articles... http://www.dotnetbips.com/displayarticle.aspx?id=125 http://ww...

Add a new row after current row in gridview
Is there a way to add a new row after the current row in a gridview by clicking a "+" add button, that is beside that current row.   Or is there a way with forms view to have a row of text boxes for data entry then you click the "+" add button beside that row of textboxes and a new row appears below for data entry?  Thanks Hi, Check below link whose last line is available for entry of a new row: http://www.gridviewguy.com/ArticleDetails.aspx?articleID=139 You can set footer to invisible by default and set it to visible by clicking "+" button.NOTE:If you find m...

Add a new row by duplicating existing row?
How can I add a new row by duplicating existing row? What must I do after triggering the event pfc_addrow()? Should I use datastore to store the existing datawindow values? Thanks. qtran@ladwp.com ---== Posted via the PFCGuide Web Newsreader ==--- http://www.pfcguide.com/_newsgroups/group_list.asp RowsCopy(.....) is your friend... -- pbm_thisusuallydoesnothelp :-)) "Q Tran" <see_message_body@domain.com> wrote in message news:h33nIbM0$GA.299@forums.sybase.com... > How can I add a new row by duplicating existing row? > What must I do after triggering th...

how to add new row in middle of the rows in Datatable?
my datatable isNo item1      102       303       50i want to add one row in between 2 and 3.  Is this possible?thanks in advance You need to understand that there is no particular order in which SQL Server stores data in the tables. So unless you specify an order by clause in the SQL statement there is no sense in talking about  the order of data in the table. ***********************Dinakar NethiLife is short. Enjoy it.*********************** Here Datatable means, DataTable in dataset(a...

Add .Net Control to Web Custom Control
 I want to add .NET Control (like: TextBox, Button...) to Web Custom Control.How i can do it? Alphavn That's called a composite control -- "Mark As Answer" if my reply helped you -- Hello Guys What gunteman said, that is one approach and in most cases the right one.But its also possible to add child controls to a Control thats inherit from WebControl itself. Be sure to implement INamingContainer to that inherited Control too, thats the important point of that approach.--Microsoft MVP - Visual Developer ASP / ASP.NET- http://www.aspnetzone.de/blogs/peterbuch...

Web resources about - Add new row at the footer issue - asp.net.presentation-controls

Wikipedia:Manual of Style/Layout - Wikipedia, the free encyclopedia
This is a guide to laying out a typical basic article. Complicated articles may be best modeled on the layout of an existing article of appropriate ...

Alyson Footer (@alysonfooter) on Twitter
Sign in Sign up To bring you Twitter, we and our partners use cookies on our and other websites. Cookies help personalize Twitter content, tailor ...

Lead-footers hit the highway in NT
Police hit out at drivers who exceeded 200km/h during first hours of an open speed limits trial.

New Footer in Mobile Google Search
Google's mobile search results pages have a new footer. Pagination elements are now centered and there's a Google logo at the bottom of the page. ...

Michael Jordan nails 50-footer at golf tournament
Watch: Sports legend Michael Jordan proved he can still hit the big shot

Texas Italian-American Sports Foundation to honor Alyson Footer
Texas Italian-American Sports Foundation to honor Alyson Footer

Alyson Footer leaves Astros for mlb.com
Alyson Footer leaves Astros for mlb.

Is Tyson Chandler the NBA's Best Dressed Seven-Footer?
... of the New Yorks Knicks, but off the court, he likes to style on people. GQ has gone so far to say that Chandler is "the slickest seven-footer" ...

Astros Boxes Podcast: Alyson Footer, Social Media and Lance Berkman
Special Guests Alyson Footer and Terri Schlather discuss social media, Jerome Williams signing and Lance Berkman

Vince Carter Throws Down Throwback Jam Over Seven-Footer Rudy Gobert
Vince Carter Throws Down Throwback Jam Over Seven-Footer Rudy Gobert

Resources last updated: 12/26/2015 10:54:07 PM