Link to home
Start Free TrialLog in
Avatar of MKItani
MKItani

asked on

datagridview+datatable+event in C#

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.
Avatar of Naman Goel
Naman Goel
Flag of India image

you can use DataGridView.RowsAdded Event for this

refer to following MSDN link for more details :

https://www.experts-exchange.com/questions/26900450/datagridview-datatable-event-in-C.html
Avatar of MKItani
MKItani

ASKER

the link is failed. it is the link of the task and not for msdn.
Please checked
ASKER CERTIFIED SOLUTION
Avatar of Naman Goel
Naman Goel
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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

Avatar of MKItani

ASKER

failed