Sunday, July 17, 2011

Bind to Grid View Using C Sharp

 SqlConnection con = new SqlConnection("Data Source=xxxx;Initial Catalog=master;Persist Security Info=True;User ID=xxx;Password=xxx");
        con.Open();
        string str = "Select * FROM Test";
        SqlCommand cmd = new SqlCommand(st, co);
        SqlDataAdapter ada = new SqlDataAdapter(cmd);
        DataSet ds = new DataSet();
        ada.Fill(ds);
        GridView1.DataSource = ds;
        GridView1.DataBind();

No comments:

Post a Comment