BINDING DATA WITH DATAGRIDVIEW

Total Post:106

Points:748
C# 
C#
 2126  View(s)
Ratings:
Rate this:
Please let me know where I am wrong

Here binding data with datagridview control in C#

SqlConnection con =        new SqlConnection("server=****\\sqlexpress; uid=sa; password=sa;         database=****");     
                                   con.Open();
            SqlDataAdapter ada = new SqlDataAdapter("select * from tableName", con);
            DataTable dt = new DataTable();
            ada.Fill(dt);
            dataGridView1.DataSource = adaa;

  1. Post:127

    Points:915
    Re: Binding data with DataGridView

    Replace this line of code
    dataGridView1.DataSource = adaa;
    with

    
       dataGridView1.DataSource = dt;   dt[DataTable name]

      Modified On Mar-29-2018 02:08:33 AM
  1. Post:106

    Points:748
    Re: Re: Binding data with DataGridView

    yes i missed that...thanks

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!