Hi i have used multiple layer in my web application.
my db of sql server 2008 is in other machine and stored procedure has defined there.
I want to retrive data from 1 table from db and bind with gridview as well as if i select 1 row that row should be display in other webform for editing.what to do?
pls write example code for this task

Hi First Crate a Data Acess Layer and craete a method there for Storeprocedur.

public static DataSet SelectSupplierContactsBySupg_id(string supg_id)
        {
            using (SqlConnection con_contacts = ConnectionManager.GetConnection())
            {
                using (SqlDataAdapter ada_contacts = new SqlDataAdapter("sprocFilteringSupplierContactsBySupg_id", con_contacts))
                {
                    ada_contacts.SelectCommand.CommandType = CommandType.StoredProcedure;
                    ada_contacts.SelectCommand.Parameters.AddWithValue("@supg_id", supg_id);
                    DataSet ds_Contacts = new DataSet();
                    try
                    {
                        ada_contacts.Fill(ds_Contacts, "SupplierGroupContacts");
                        return ds_Contacts;
                    }
                    catch
                    {

                        throw;
                    }
                    finally
                    {
                        ds_Contacts.Dispose();
                    }
                }
            }
        }

the UI layer place a grid and bind it as following.

search = txtsearch1.Text;
        //search = txtsearch2.Text;
        DataSet ds_search = new DataSet();
        try
        {
            ds_search = SupplierGroupMergerDLL.SelectSupplierContactsBySupg_id(search);
            if (ds_search.Tables[0].Rows.Count > 0)
            {
                gvFrom.DataSource = ds_search.Tables[0];
                gvFrom.DataBind();
            }

if u mean by other webform as website then change connectionstring for that particular site.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.