Solved

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

Posted on 2010-08-24
1
415 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
1 Comment
 
LVL 9

Accepted Solution

by:
rg20 earned 500 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Reading the Web.Config using IIS 7.5? 4 36
tutorial for ebay api 3 35
No Data for DropDown List 2 26
Client Validating 2 date fields, required & comparison 1 28
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

803 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