I want to cange the lables in my form according to particular value in rows. I just need how to iterate through table rows.
views:
65answers:
1
Q:
How can i iterate through row of particular table associated with SqlDataSource control in VS 2008?
A:
You can use SqlDataSource
's Select()
method to retrieve data and then you can convert the result into a DataView
or a DataReader
.
// Use the result as a DataView.
var dvSql = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);
foreach (DataRowView drvSql in dvSql)
{
Label1.Text = drvSql["FirstName"].ToString();
}
// Use the result as a DataReader.
var rdrSql = (SqlDataReader)SqlDataSource2.Select(DataSourceSelectArguments.Empty);
while (rdrSql.Read())
{
Label2.Text = rdrSql["LastName"].ToString();
}
rdrSql.Close();
Kosala Nuwan
2010-03-05 05:51:52