views:

65

answers:

1

I want to cange the lables in my form according to particular value in rows. I just need how to iterate through table rows.

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