I’m trying to output the result of my SQL query to a div using the InnerHTML. but I can’t get more than one record to show up. How do I make it so that all of my records are displayed in the DIV? On my page I have the DIV contained within a UpdatePaneland I only 1 row is displayed even when the query returns more than one row.
string sql = "Select * From Events";
SqlCommand command = new SqlCommand(sql, conn);
command.CommandType = CommandType.Text;
conn.Open();
reader = command.ExecuteReader();
while (reader.Read())
{
divout1.InnerHtml += "Name: " + reader["Name"].ToString() + "<br />" +
"Date: " + reader["Date"].ToString() + "<br />" +
"Location: " + reader["Location"].ToString() + "<br />";
divout.Visible = true;
}
Well, at first look, unless your query returns only one row, it should get all data on your div.
try to put a break point on the last bracket of your while statement and see what happens on your div after first iteration.
for other way, try to put the div out of the updatepanel to see what appens?