473,407 Members | 2,326 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,407 software developers and data experts.

Adding rows to a gridview

47
Here's the deal. I have a gridview that I need to fill by adding one record at a time. Is there a procedure for inserting a record in a gridview?
Apr 7 '09 #1
8 2312
Frinavale
9,735 Expert Mod 8TB
Add the row to the Object that you are using as the data source for the GridView and it will appear in your GridView.

-Frinny
Apr 7 '09 #2
kimbred
47
The values of several of the columns are dependent on other columns in the rows so I wanted to evailuate the data defore displaying it in the grid. From what I've read, it's not possible to insert rows into a dataview one by one programically. I'm not sure I understand your solution.
Apr 7 '09 #3
Frinavale
9,735 Expert Mod 8TB
See you never mentioned the use of a DataView so I wasn't exactly sure what you were doing.

To do this you need to dynamically create a DataTable.
Then create a new DataView based on this DataTable:

Expand|Select|Wrap|Line Numbers
  1. Dim dynamicTable As DataTable = createDataTable()
  2. Dim myDataView As New DataView(dynamicTable)
  3. myGridView.DataSource = myDataView;
  4.  
Apr 7 '09 #4
kimbred
47
So all my modification will be to the data table then the dataview will just use the data table as a source. Is that correct?
Apr 7 '09 #5
dorandoran
145 100+
It is EXTREMELY pain in everywhere to insert a record using Gridview. Here is a good article yet painful.

http://fredrik.nsquared2.com/viewpost.aspx?PostID=155
http://aspnet.4guysfromrolla.com/articles/021203-1.aspx
http://amitpatriwala.wordpress.com/2...-in-aspnet-20/
http://www.dotnetspider.com/resource...-Database.aspx
http://www.c-sharpcorner.com/uploadf...e&user=qarjami

I have 10 more links on this. let me know if these dont help. Good Luck
Apr 7 '09 #6
Frinavale
9,735 Expert Mod 8TB
@kimbred
Well once it's in the DataView you can access the table and edit the data there, yes.
Apr 8 '09 #7
kimbred
47
Is that the way you'd do it?
Apr 8 '09 #8
Frinavale
9,735 Expert Mod 8TB
Yup.

It's not pretty and I'm sure that there is a more elegant way to do it (using a different Object as the datasource).

But it's not as bad as it sounds. Especially if you are grabbing data from a database because you'll likely already have a table at that point.

In my case I'm converting Objects into a table, so it's a bit messier than your solution will be. Well it's only messy for the table generation part really, after that it's not so bad. It's been a long time since I've used a database (hope that will change in the near future).
Apr 8 '09 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: VMI | last post by:
I'm working on a questionaire, and I'd like to add the questions to a gridview, so that each row (of two "columns" each) has the question in one field, and the editable section (where the user will...
1
by: Loading name... | last post by:
hey asp.net 2.0 Is it possible to add records to a database via a GridView, I mean in the GridView the user add new rows which are saved back to the database? I know I can edit rows, but...
1
by: JB | last post by:
I'm dynamically creating a Gridview object and filling it with contents from an ArrayList as follows: GridView2.AutoGenerateColumns = true; GridView2.DataSource = ArrayListObject;...
2
by: Blasting Cap | last post by:
I've got a gridview (that I converted over from a datagrid, which had been working properly), that is doubling up the number of rows returned. When it was running as a datagrid, the same code sent...
0
by: ganesh22 | last post by:
Hi... Iam using GridView in asp.net(2.0) .My requirement is user can add,update,delete in gridview I written the code for add & update but can u help adding rows in grid view My code: ...
1
by: bJames | last post by:
Hi I've been all around looking for an answer to this question, but can't find it. I've got a gridview with a single unbound column. It's got a textbox and button in the footer row. I"m trying to...
2
by: Michael | last post by:
It seems that a gridview allows us to delete only a single row at a time. How to extend this functionality to select multiple rows and delete all of the selected rows in a single stroke? just like...
1
by: COHENMARVIN | last post by:
I have a gridview and I need to know the number of rows in it. I find the Page_load and the Gridview_Load events are too early to find out the number of rows. I can use the Gridview_databound...
2
by: shrikanthn | last post by:
Hi All, i am adding some data into GridView (adding 4 to 5 rows) at runtime in asp.net page using c#. but getting outofbond error.
7
by: =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?= | last post by:
I'm adding subheadings to a gridview. Each sub head has a few link buttons. I'm adding the controls in the rowdatabound event code follows: sorry about the length here. I have to be missing...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.