473,397 Members | 1,949 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Add row to datagrid without databinding again

Hi,

Is there a way to add a row to a datagrid after DataBind method is called. I
know I can call DataBind again, but that's not what I am looking for.

The reason I want to do this, I have a page to load data into a DataGrid and
let user edit data, now I want to add function for user to add data also.
The problem, this is All-Or-None situation, the user add/change several rows
then save all rows together or do nothing at all.

Thanks in Advance for any suggestions
Nov 19 '05 #1
1 1716
Not the ideal solution, but a work around.

When you say you don't want to databind it again, i take it you concerned
about the trip to the database.

So what you can do, is take the DataSource out of the DataGrid, add a new
row and rebind it. (avoiding a new trip to the database, but still
rebinding)

so if your grid was called MyGrid and it was Bound to a DataTable:

DataTable dt = (DataTable)MyGrid.DataSource; //for a DataSet --> DataSet
ds = (DataSet)MyGrid.DataSource;

//Add a new row to this datatable then rebind

MyGrid.DataSource = dt;
MyGrid.DataBind();

HTH

"Ed Chiu" <Ed****@discussions.microsoft.com> wrote in message
news:38**********************************@microsof t.com...
Hi,

Is there a way to add a row to a datagrid after DataBind method is called.
I
know I can call DataBind again, but that's not what I am looking for.

The reason I want to do this, I have a page to load data into a DataGrid
and
let user edit data, now I want to add function for user to add data also.
The problem, this is All-Or-None situation, the user add/change several
rows
then save all rows together or do nothing at all.

Thanks in Advance for any suggestions

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Stephan Steiner | last post by:
Hi I'm using several DataTables in my program which are updated periodically. At the same I have those tables bound to DataGrids in my GUI. So far I've been doing all the processing in the same...
5
by: sdbranum | last post by:
I have been using Visual C#.NET to code a large project having many data adapters, data sets, datagrids, multiple forms with tab pages, each containing various controls (mostly label, text boxes,...
1
by: Michelle Stone | last post by:
Hi all. I have an empty datagrid on my web form. And I add BoundDataColumn(s) to it through code. But after each postback, the columns and rows disappear. As a workabout, I tried to rebind the...
8
by: Jeff | last post by:
Hi - I'm having trouble Databinding a SQLDataReader to a DataGrid control. I have an ASP.NET web page accessing a SQL database. I've used VS to build the app and stored it in a directory of...
4
by: hope | last post by:
Hi, How can I format a string field using Data Formatting Expression property in datagrid? For example: format last name from BROWN to Brown. Thanks
0
by: Daniel Doyle | last post by:
Hello and apologies in advance for the amount of code in this post. I've also sent this message to the Sharepoint group, but thought that ASP.NET developers may also be able to help, even though...
10
by: Nick | last post by:
Hello, Please pardon my ignorance as I'm sure this is easy to do. I have a datagrid where I want to let the user delete columns. I added a context menu to the datagrid that has a delete option....
4
by: Jeff User | last post by:
Hi I tryed to solve this problem over in the framework.asp group, but still am having trouble. Hope someone here can help. using .net 1.1, VS 2003 and C# I have an asp.DataGrid control with a...
0
by: mcollier | last post by:
I'm trying to develop a page template for the ASP.NET 1.1 project I'm working on. I want to have something like Master Pages (from ASP.NET 2.0). I'm having a problem now with databinding on a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.