using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.Common;
using System.Data.ProviderBase;
using System.Data.SqlTypes;
using System.Data.Sql;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
SqlConnection conn = new SqlConnection("Data Source=CTS\\MSSQLSERVER2008;uid=sa;pwd=home;Initial Catalog=Northwind");
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
loadMyGrid();
}
}
public void loadMyGrid()
{
conn.Open();
SqlDataAdapter sda = new SqlDataAdapter("select EmployeeID,FirstName +"+"' '+"+"LastName as Name,Title,Address,City,Region,Country from employees", conn);
DataSet ds = new DataSet();
sda.Fill(ds);
DataViewManager dvm = new DataViewManager(ds);
dvm.DataViewSettings["Employees"].RowFilter = "Country='USA'";
dataGrid.SetDataBinding(dvm,"Employees"); \\ This SetDataBinding( ) is not available in VS 2010
GridView1.DataSource = ds;
GridView1.DataBind();
conn.Close();
}
}
What namespace should i import in order to run this code successfully??? Help me out guys...
Thanks in advance...
Hi Monhan Kumar,
You can use the DataTable concept instead of DataViewManager and DataViewSettings.
check this code,
It might be resolve your problem.