Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to add rows to GridView by clicking on a button?

Posted on 2010-08-24
1
Medium Priority
?
424 Views
Last Modified: 2013-11-05
Hi,

I'm developing a sharepoint custom field. In my class, which inherits from BaseFieldControl class, and particularly in the method "CreateChildControls", I created a DataTable, and I inserted two rows into it.
Also, I have a GridView with 4 columns. The dataSource for this GridView is the above DataTable.
Then, I have 4 text box fields and a button "Add".
When clicking on "Add" button, I create a new row with the values entered in the text box fields, then I add this row to the Datatable, then I rebind the datatable to the GridView as a DataSource.
 So the new row appears in the GridView.
But , if I fill in again the 4 fields and click on "Add", I got that the new row replaces, in the GridView, the row that I have added when I clicked on the "Add" button for the first time.
While, the required result is to see the second row with the first one in the GridView.
And, if I count the number of rows in the GridView, I found that the inserted rows by clicking on "Add" button are not considered.
So, how can I resolve it?

Thanks.
0
Comment
Question by:pgirardier
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 9

Accepted Solution

by:
rg20 earned 1500 total points
ID: 33512787
You would have to maintain a list of data as static data
or check that you don't remove it on postback

static List<string> data = new list<string>();
string record;
string newdata;

data.add(record);
data.add(record);
data.add(newdata);
data.add(newdata);

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question