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