I have a web form that populates data from the database. That part works fine. I have a database that has a User ID and different Unit IDs. I know I could just make a Grid View to display all of the data just for that user but I wanted to know if there is a way to do it to a textbox?
Example:
USER | Unit ID | Car | Truck |
100 | 200 | 1 | 2 |
100 | 300 | 3 | 4 |
100 | 400 | 6 | 7 |
How can this data be populated into textboxes?
Here is the current code I use to populate textboxes:
if (TextBoxINST_ID.Text.Trim().Length > 0)
{
SqlConnection con3 = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["HotConnectionString"].ConnectionString);
con3.Open();
SqlCommand scmd3 = new SqlCommand("Select FT_UNDERGR, FT_GRAD, FTE_UNDERG, FTE_GRAD, NON_CREDIT, TOTAL_FTE, FCFTUHC, FCFTPBHC, FCPTUHC, FCPTPBHC, NCHC, FTE40, HC50, FTE4050, UnderG12, Postb9, Total123b4b, THCAS from Table88 where User_ID = '" + TextBoxUser_ID.Text + "'", con3);
SqlDataReader dr3 = scmd3.ExecuteReader();
if (dr3.Read())
{
TextBoxFTUG2.Text = dr3["FT_UNDERGR"].ToString();
TextBoxFTG2.Text = dr3["FT_GRAD"].ToString();
TextBoxTHUGDR2.Text = dr3["FTE_UNDERG"].ToString();
TextBoxTHGDR2.Text = dr3["FTE_GRAD"].ToString();
TextBoxNCCDR2.Text = dr3["NON_CREDIT"].ToString();
TextBoxTCNC2.Text = dr3["TOTAL_FTE"].ToString();
TextBoxTNFUG2.Text = dr3["FCFTUHC"].ToString();
TextBoxTNFG2.Text = dr3["FCFTPBHC"].ToString();
TextBoxTNCPUG2.Text = dr3["FCPTUHC"].ToString();
TextBoxTNCPG2.Text = dr3["FCPTPBHC"].ToString();
TextBoxTNNCC2.Text = dr3["NCHC"].ToString();
TextBoxFTE402.Text = dr3["FTE40"].ToString();
TextBoxHC502.Text = dr3["HC50"].ToString();
TextBoxFTE40502.Text = dr3["FTE4050"].ToString();
TextBoxTHUG2.Text = dr3["UnderG12"].ToString();
TextBoxTHG2.Text = dr3["Postb9"].ToString();
TextBoxT12342.Text = dr3["Total123b4b"].ToString();
TextBoxTHCAS2.Text = dr3["THCAS"].ToString();
ButtonSubmit2.Visible = true;
}
con3.Close();
dr3.Close();