Solved

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

Posted on 2010-08-24
1
420 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 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

691 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