aspx:
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server" CellPadding="4" ForeColor="#333333" GridLines="None">
<FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
<PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
<HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
</div>
</form>
cs:
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string ConnectionString = "server=(local);User id=sa;pwd=sa;database=Northwind";
string Sql = "select CustomerID,CompanyName,Country from Customers";
SqlConnection conn = new SqlConnection(ConnectionString);
SqlDataAdapter adp = new SqlDataAdapter(Sql,conn);
DataTable table = new DataTable();
adp.Fill(table);
DataView dataView = new DataView(table, "Country='USA'","CompanyName Desc", DataViewRowState.CurrentRows);
GridView1.DataSource = dataView;
GridView1.DataBind();
}
}