Solved

datagridview+datatable+event in C#

Posted on 2011-03-21
5
314 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
[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
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Suggested Courses

627 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