Hello,
I have a problem with disappearing datagrids.
I have a DG (dgFinance) on the aspx page. I execute my SQL in the Page_Load section and assign the dataset to the datagrid on the aspx page.
DataSet ds = myBusinessLogicObject.DoSQLReturnDataset();
dgFinance.DataSource = ds;
dgFinance.DataBind();
I have tried two scenarios with and without the IsPostBack - as I only really want to go to the database once (on the 1st page load).
Scenario 1 - not using IsPostBack (so the DG is rebound to a new SQL result after every mnouse click!!)
I am using an Edit/Update/Cancel column. I can select Edit and the column changes to update / cancel. When I select update - nothing happens. I can't see the old values. When I stop the code in the dgFinance_UpdateCommand the DataGrid and DataSource contain the old values, so I can't even update the real database. How do I get the new values? -- I think it may be because I am going to the database and 'resetting' the datagrid every time a Page_Load kicks in.
However ...
Scenario 2 - I am using IsPostBack to ensure my SQL is executed once and only once.
If I use IsPostBack ...
if (!IsPostBack)
{
DataSet ds = myBusinessLogicObject.DoSQLReturnDataset();
dgFinance.DataSource = ds;
dgFinance.DataBind();
}
... to ensure that I only physically go the database once. When I select the edit action and breakpoint on the first line in Page_Load I can see fully constructed dgFinance object. But it isn't displayed. From a users perspective you click edit on a row and the whole dataset disappears - Why? The page seems to have a fully constructed dgFinance object - so why doesn't it show.
OK so thats the background, heres my question :
I have looked at many, many examples and most only show code embedded into the aspx file in script tags. The only examples I have found that bind via CodeBehind files do not use the IsPostBack, but I don't want to go to the database after every mouse click. How do I get the new value edited in the text box????
Thanks in advance,
Simon
I have a problem with disappearing datagrids.
I have a DG (dgFinance) on the aspx page. I execute my SQL in the Page_Load section and assign the dataset to the datagrid on the aspx page.
DataSet ds = myBusinessLogicObject.DoSQLReturnDataset();
dgFinance.DataSource = ds;
dgFinance.DataBind();
I have tried two scenarios with and without the IsPostBack - as I only really want to go to the database once (on the 1st page load).
Scenario 1 - not using IsPostBack (so the DG is rebound to a new SQL result after every mnouse click!!)
I am using an Edit/Update/Cancel column. I can select Edit and the column changes to update / cancel. When I select update - nothing happens. I can't see the old values. When I stop the code in the dgFinance_UpdateCommand the DataGrid and DataSource contain the old values, so I can't even update the real database. How do I get the new values? -- I think it may be because I am going to the database and 'resetting' the datagrid every time a Page_Load kicks in.
However ...
Scenario 2 - I am using IsPostBack to ensure my SQL is executed once and only once.
If I use IsPostBack ...
if (!IsPostBack)
{
DataSet ds = myBusinessLogicObject.DoSQLReturnDataset();
dgFinance.DataSource = ds;
dgFinance.DataBind();
}
... to ensure that I only physically go the database once. When I select the edit action and breakpoint on the first line in Page_Load I can see fully constructed dgFinance object. But it isn't displayed. From a users perspective you click edit on a row and the whole dataset disappears - Why? The page seems to have a fully constructed dgFinance object - so why doesn't it show.
OK so thats the background, heres my question :
I have looked at many, many examples and most only show code embedded into the aspx file in script tags. The only examples I have found that bind via CodeBehind files do not use the IsPostBack, but I don't want to go to the database after every mouse click. How do I get the new value edited in the text box????
Thanks in advance,
Simon