0

I am trying to display all the TrailerNo from ICDTmpTrailerMovemnt table in lblTrailerNo label using following code.But it is showing the first row value multiple times But how can i fetch all the rows of that particular column like

CMDHA-610023 CMDHA-610024 CMDHA-610026 CMDHA-610027 CMDHA-610028 CMDHA-610029 CMDHA-610030 CMDHA-610031 etc

    String con = dbcon;
    String SQL = "select TrailerNo from ICDTmpTrailerMovemnt";
    SqlDataAdapter Adpt = new SqlDataAdapter(SQL, con);
    DataSet ds = new DataSet();
    Adpt.Fill(ds);

    foreach (DataRow dr in ds.Tables[0].Rows)
    {
        lblTrailerNo.Text += ds.Tables[0].Rows[0]["TrailerNo"].ToString() + "<br />";

    }

1 Answer 1

3
foreach (DataRow dr in ds.Tables[0].Rows)
{
    lblTrailerNo.Text += dr["TrailerNo"].ToString() + "<br />";

}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.