0

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

2
Contributors
2
Replies
4
Views
7 Years
Discussion Span
Last Post by Bonx
0

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

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

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

/ Brian

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.