Solved

datagridview+datatable+event in C#

Posted on 2011-03-21
5
311 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

840 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