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");
            daContactPerson.Fill(dsContactPerson);
            daContactPerson.Fill(dtContactPerson);

            // 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

Hi

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

Textbox1.txt=Gv1.rows.cels[1].text;

Thanks,
Paul daniel

Textbox1.txt=Gv1.rows.cels[1].text;

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

/ Brian

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.