Dear Lee....
Please find the code attached with below, this might solve ur problem.
Steps to check: Once you load the page with data, refresh it (F5), then
change the data at the back end and again refresh you will see the changes
are not reflected, then click the button on the page it will get the fresh
data from the server.
Regards,
Shailesh MG
Code ====================
/* you should have a datagrid1 and button1 on the aspx page and the proper
connection string.
===========================
private void Page_Load(object sender, System.EventArgs e)
{
ConnStr = "server=ILDC1\\SQLRND;initial catalog=Northwind;uid=sa;pwd=";
// Change this as per your need
if (Session["Data"] == null )
GetData();
else
{
ds = (DataSet)Session["Data"];
DataGrid1.DataSource = ds.Tables[0].DefaultView;
DataGrid1.DataBind();
}
}
private void GetData()
{
SqlConnection Conn = new SqlConnection(ConnStr);
CommStr = new StringBuilder("");
ds = new DataSet();
CommStr.Append(" select P.ProductID, P.ProductName, C.CategoryName,
UnitPrice from products P, Categories C where ");
CommStr.Append(" C.categoryid = P.categoryid order by productName ");
SqlDataAdapter sda = new SqlDataAdapter(CommStr.ToString() ,Conn );
sda.Fill(ds,"First");
Session["Data"] = ds;
DataGrid1.DataSource = ds.Tables[0].DefaultView;
DataGrid1.DataBind();
}
private void Button1_Click(object sender, System.EventArgs e)
{
GetData();
}
"Lee Price" <an*******@discussions.microsoft.com> wrote in message
news:4d****************************@phx.gbl...
Hi all,
I have a bound datagrid which is filled with data and
displayed.Now on the click of a button I need to refill
the datagrid with new data but the problem is the
datagrid mixes up the new data with the old data.
I have stored the data in a session variable which seems
to get updated although I am not altering the value of
the session variable
does binding a datagrid to a session variable update the
session variable also.
how do i reset my datagrid to take fresh values