I created a program and one of its function is when you select an item from the dropdownlist, the data from database will automatically populate to the textbox. I have 16 texboxes and problem was, when I click the a selection, only 1 data from the DB will populate to the 16 textboxes. To help me explain clearly, please see the attached picture of my codes and DB. By the way, I am only a novice in programming. Thanks you in advance.
Loading

Jes SiePosted Sep 21, 2016, 9:10 AM
Esakki MuthuPosted Sep 20, 2016, 2:20 AM
Jes SiePosted Sep 18, 2016, 11:20 PM
Jes SiePosted Sep 18, 2016, 10:08 PM
Nitin Sontakkeif you were able to read the question I posted, I emphasize that I am novice in C# programming. I learned only by tutorials and forums like this. A detailed instruction will help me a lot. Anyway, thanks for the advice though.
Delpin Susai RajPosted Sep 18, 2016, 3:08 AM
Nitin SontakkePosted Sep 18, 2016, 12:55 AM
Jes SiePosted Sep 17, 2016, 2:49 AM
Jisny AvPosted Sep 16, 2016, 4:15 AM
txtCoverageBenefit.Text = ds.Tables[0].Rows[i]["Amount"].ToString();
Nitin SontakkePosted Sep 16, 2016, 3:46 AM
Nitin SontakkePosted Sep 16, 2016, 3:43 AM
Bikesh SrivastavaPosted Sep 16, 2016, 3:34 AM
Jes SiePosted Sep 16, 2016, 3:32 AM
Nitin SontakkePosted Sep 16, 2016, 3:15 AM
Jes SiePosted Sep 16, 2016, 3:01 AM
Midhun T PI tried your suggestion but I got only this result
Jes SiePosted Sep 16, 2016, 2:46 AM
Server Error in '/' Application.
Value cannot be null.
Parameter name: dataSet
Jes SiePosted Sep 16, 2016, 2:43 AM
Jisny AvPosted Sep 16, 2016, 2:11 AM
{
using (SqlConnection SqlCn = DBConnection.GetDbCon())
{
String strQuery = "select HPAPlan, Amount from tblHPACoverageBenefits where HPAPlan = @HPAPlan";
SqlCommand cmd = new SqlCommand();
cmd.Parameters.AddWithValue("@HPAPlan", ddlHPACoverage.SelectedItem.Text);
cmd.CommandType = CommandType.Text;
cmd.CommandText = strQuery;
cmd.Connection = SqlCn;
try
{
SqlCn.Open();
// SqlDataReader sdr = cmd.ExecuteReader();
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
DataSet ds = null;
adapter.Fill(ds);
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
TextBox txtCoverageBenefit = (TextBox)Page.FindControl("txtCoverageBenefit" + i);
txtCoverageBenefit.Text = ds.Tables[0].Rows[i]["Amount"].ToString();
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
SqlCn.Close();
SqlCn.Dispose();
}
}
}
Vaibhav DeshmukhPosted Sep 16, 2016, 1:54 AM
Midhun TpPosted Sep 16, 2016, 1:49 AM