I want to call a function when double clicking on a DataGridView row that retrieves the data from SQL Server and displays it in the appropriate checkbox, textbox, etc.
The issue is I have a couple dozen columns in the query that need to be displayed. There has to be a better way to do this rather than have 2 dozen arguments in the function. I just don't know what they might be.
I have something similar to this currently.
The issue is I have a couple dozen columns in the query that need to be displayed. There has to be a better way to do this rather than have 2 dozen arguments in the function. I just don't know what they might be.
I have something similar to this currently.
C#:
public void GetFac(string ID, CheckBox chk1, CheckBox chk2, TextBox txt1, TextBox txt2.....TextBox txt22)
{
SqlConnection myDB= new SqlConnection(connP);
SqlCommand getLoc = new SqlCommand("MySP", myDB);
getLoc.CommandType = CommandType.StoredProcedure;
getLoc.Parameters.AddWithValue("@ID", ID);
misc.Open();
SqlDataReader dr = null;
dr = getFac.ExecuteReader();
while (dr.Read())
{
chk1.Checked = (Convert.ToBoolean(dr["col1"].ToString()));
chk2.Checked = (Convert.ToBoolean(dr["Col2"].ToString()));
chk3 = (Convert.ToBoolean(dr["Col3"].ToString()));
...
...etc
}
}