I want to cange the lables in my form according to particular value in rows. I just need how to iterate through table rows.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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 dataview = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);
foreach (DataRowView dataviewrow in dataview)
{
Label1.Text = dataviewrow["FirstName"].ToString();
}
// Use the result as a DataReader.
var datareader = (SqlDataReader)SqlDataSource2.Select(DataSourceSelectArguments.Empty);
while (datareader.Read())
{
Label2.Text = datareader["LastName"].ToString();
}
datareader.Close();
标签:
sqldatasource