// Arquivo de exemplo: DataView.aspx.cs
using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Web.Configuration;

public partial class DataView1 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            ConnectionStringSettings getString = WebConfigurationManager.ConnectionStrings["nwind"] as ConnectionStringSettings;
            if (getString != null)
            {
                string sSql = "Select ProductName from Products";
                using (SqlConnection conn = new SqlConnection(getString.ConnectionString))
                {
                    DataSet ds = new DataSet();
                    SqlDataAdapter adapter = new SqlDataAdapter(sSql, conn);
                    adapter.Fill(ds, "Produtos");
                    DataView dv = ds.Tables[0].DefaultView;
                    dv.RowFilter = "ProductName Like 'C%'";

                    foreach (DataRowView dr in dv)
                    {
                       Label1.Text+=dr["ProductName"].ToString() + "<br/>";
                    }
                }
            }
        }
    }
}
