Showing posts with label Calling Data into the Grid through DataSet. Show all posts
Showing posts with label Calling Data into the Grid through DataSet. Show all posts

Friday, January 16, 2009

Calling Data into the Grid through DataSet

The Code Behind of the Button Click Event

protected void btnCustomerID_Click(object sender, EventArgs e)
    {
Customer objCustomer=new Customer();
//gv=GridView
        gvCustomers.DataSource = objCustomer.Select();
        gvCustomers.DataBind();
    }

The DataSet Method in a Seperate Class

SqlConnection conn=new SqlConnection("server=sheeban\\sqlexpress;integrated security=SSPI;database=northwind");
    SqlCommand cmd = new SqlCommand("SELECT * FROM customers", conn);
    SqlDataAdapter da=new SqlDataAdapter(cmd);
    DataSet ds = new DataSet();
    da.Fill(ds);
    return  ds;