4
Answers

Add combobox to dataGridView

Dealy

Dealy

10y
1.3k
1
Hello,
 
I load data from a database into a dataGridView. How can I set one of the columns to combobox that loads data from a stored procedure?
Here's my code for loading data:
 
using (conn = new SqlConnection(connectionString))
{
SqlCommand cmd = new SqlCommand("SELECT_TASKS", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("@UserID", System.Environment.UserName));
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
tasksGridView.DataSource = dt;
}
conn.Close();
 
Thank you in advance. 

Answers (4)