Solved

datagridview+datatable+event in C#

Posted on 2011-03-21
5
305 Views
Last Modified: 2012-05-11
hi all,
I am using C#+window application.

my code is as follow:
datagridview1.datasource=dataTable1;

What is the names of the events that i can use  to write my code before add new row add after add a new row to the datagridview during the binding source.
0
Comment
Question by:MKItani
  • 2
  • 2
5 Comments
 
LVL 13

Expert Comment

by:Naman Goel
ID: 35182231
you can use DataGridView.RowsAdded Event for this

refer to following MSDN link for more details :

http://www.experts-exchange.com/Programming/Languages/C_Sharp/Q_26900450.html
0
 

Author Comment

by:MKItani
ID: 35182289
the link is failed. it is the link of the task and not for msdn.
Please checked
0
 
LVL 13

Accepted Solution

by:
Naman Goel earned 500 total points
ID: 35182311
0
 
LVL 6

Expert Comment

by:r3nder
ID: 35182393
Here is what I do
             
if (Whatever the condition)
        {
            
            SqlConnection con = new SqlConnection("user id=user;" +
                                           "password=pass;server=127.0.0.0;" +
                                           "Trusted_Connection=yes;" +
                                           "database=db; " +
                                           "connection timeout=30");
           // Retrieving data from Stored Proceedure and bind it to datagrid
           try
           {
               con.Open();
               SqlCommand com = new SqlCommand("spx_storedProcName", con);
               com.CommandType = CommandType.StoredProcedure;
               SqlDataAdapter adapter = new SqlDataAdapter(com);
               DataTable tbl = new DataTable();
               adapter.Fill(tbl);
               DataGrid1.DataSource = tbl;
               DataGrid1.DataBind();
               Response.Write(DataGrid1.Columns[1].ToString());
               
               

           }
           catch (Exception ex)
           {
               Response.Write(ex.Message);
               con.Close();
           }

        }

Open in new window

0
 

Author Closing Comment

by:MKItani
ID: 35431824
failed
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
This video discusses moving either the default database or any database to a new volume.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

707 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now