Do you feel the deifference between rows and columns?
SqlDataReader.GetValue(columnindex)
returns the value of the specified column. If you specify
count
(in this case is equal to zero, because in
SELECT
statement you specify only one column), the data are entered only to
TextBox0
control.
int count = 0;
while(sqlreader.Read())
{
Control mTextBox = FindControl("TextBox" + count.ToString());
mTextBox.Text = sqlReader.GetValue(0).ToString();
count+=1;
}
For further information, please see:
SqlDataReader class[
^]
Control.FindControl Method (String)[
^]