BINDING DATA WITH DATAGRIDVIEW

John Smith

Total Post:103

Points:727
Posted by  John Smith
C# 
C#
 2028  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. Uttam Misra

    Post:126

    Points:906
    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. John Smith

    Post:103

    Points:727
    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!