First of all, normally i create web apps, so i'm a newbie to winforms.

I have created a dataset with data from my DB and using that as my datasource for my gridview, a little bit of code:

// Define Connection string
            string DB_ConnStr = ConfigurationManager.ConnectionStrings["SupportTool.Properties.Settings.DB_Contact_ConnStr"].ConnectionString;

            // Define SQL Connection
            SqlConnection DB_Conn = new SqlConnection(DB_ConnStr);

            // Define SQL Command from Stored Procedure
            SqlCommand cmd = new SqlCommand("GetAllContactPerson", DB_Conn);
            cmd.CommandType = CommandType.StoredProcedure;

            // Create DataAdapter
            SqlDataAdapter daContactPerson = new SqlDataAdapter();
            daContactPerson.SelectCommand = cmd;

            // Create DataSet & DataTable
            DataSet dsContactPerson = new DataSet();
            DataTable dtContactPerson = new DataTable();

            // Fill dataSet & DataTable with Data from DataAdapter
            //daContactPerson.Fill(dsContactPerson, "Create DS");

            // Use dataset as datasource for gridview
            gvwContactPerson.DataSource = dsContactPerson.Tables[0].DefaultView;

What i wan't is, when i click some where in the grid, it should take the data from that specific row and put it into my textboxes, but i'm lost.

I have a column which holds an unique ID for each row.

Best regards,

Brian Olsen


Directly u get d values from gridview to textbox while in button click event
Try this code


Paul daniel


i'm not getting the opportunity to select gv1.Rows.Cells in VS.

/ Brian

This article has been dead for over six months. Start a new discussion instead.