I am trying to get value from the databse and assign it to the label using the below line:
lblQuestion.Text = ds.Tables[0].Rows[0]["Question"].ToString();
but it assigns as label.
if (ds.Tables[0].Rows.Count > 0)
{
lblQuestion.Text = ds.Tables[0].Rows[0]["Question"].ToString(); ;
}
UPDATED – Deleted my last info now that you have included the code….
Have you stepped through your code to see if any data is returning?
AKA – is
ds.Tables[0].Rows.Count > 0?You are also doing
!Page.IsPostBack. This will only call the code and load your labels if it’s on the first load…. What about subsequent loads? The labels will return back to whatever they defaulted to in the designer…..