Register  |  Login




Advertisement

Start Your Own Q&A Site

Create your own Q&A site easily, allowing you to quickly grow a new community around any subject matter or generate new organic traffic for your existing website.

Question

Status: Open Points: 25 Time: 03:48 - Mar 06, 2009  

rupamnupur

data gridview tasks

i have msaccess database
i am working for website in asp using C#
i use datagrid for db conectivity &also enable edit and DELETE from it
now i want to add new data to datagrid
which may b possile by enable adding
but the problem is that it is not been showing in task bar
i am using VISUAL STUDIO 2005
please solve my problem

Categories

Answer Discussion
Tutorials

 

nidhi

Date:: Mar 08, 2009

Time:: 05:40

What you can do is create a new datarow and add that to a datatable. That then goes to a dataview which you associate to the datagrid. This example is in vb.net but it should be easy enough to translate to c#

Ive added comments in to help you out

'Define a datatable, datarow and dataview
Dim dt As DataTable
Dim dr As DataRow
Dim dw As DataView


'Associate the currnt datasource to the data table
dt = DataGrid1.DataSource

'Create a new row
dr = dt.NewRow()

'Populate the fields in that datatable
dr("ID") = "100"
dr("MyValue") = "Quomon"

'Add this new DataRow to the DataTable
dt.Rows.Add(dr)

'Now add that DataTable to a new instance of a DataView
dw = New DataView(dt)

'And finally add that dataview to the DataGrid datasource
DataGrid1.DataSource = dw

nidhi

Date:: Mar 08, 2009

Time:: 05:42

I think this is the c# equivalent

It assumes u have a datagrid control called dataGrid1
and datasource has 2 columns ID and MyValue

   DataTable dt;
   DataRow dr;

   dt = DataGrid1.DataSource;

   dr = dt.NewRow();
   dr("ID") = "100"
   dr("MyValue") = "Quomon"
   dt.Rows.Add(dr)

   DataView dw = new DataView(dt);
   dataGrid1.DataSource = dw;

admin

Date:: Apr 06, 2009

Time:: 06:01

The question looks to be abandoned by the user who asked it. If no action is taken within 2 days, a Quomon Moderator will consider closing the question and distributing the points.

The Quomon Team

Answer this Question

New User

Email:

Upon submission of this form, you will automatically be registered as a Quomon user and we will send your login information to this address

Registered User

Username:

Password:

Forgot Your Password?

Tutorials cannot be submitted until the Answer Discussion is complete.

Submit answers in the Answer Discussion area

Ask a Question

Have a new question? Ask!

You have 100 characters to use



Top Experts

View More

Rank

Expert

Points

1.

nidhi

10354

2.

oracleofDelphi

6493

3.

rcastagna

5596

4.

LAGM

4848

5.

PeterNZ

3487

6.

gonzalo

2840

7.

Mason

2770

8.

jgivoni

2303

9.

xarcus

1820

10.

Anpanman

917

Become an Expert

Register today to share your knowledge with the community and be recognized and rewarded for your contributions.


Register Here




"Psst, Quomon is a great site. Pass it on."     Tell a Friend  |   Link To Us  |   Save to Delicious  |   Digg! Digg it



Language Options

English:

www.quomon.com

Español:

www.quomon.es