G
Guest
Hello everybody, I got myself a strange problem
I have a DataGrid in the page, nothing special about it, only it connects datasource programatically and it supports paging.y. So the code is something like this
private void Page_Load(object sender, System.EventArgs e
if (!IsPostBack
GridBind()
private void GridBind(
myGrid..DataSource = GetSomeDataSource()
myGrid.DataBind()
private void PageChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e
myGrid.CurrentPageIndex = e.NewPageIndex
BindData()
This worked perfectly OK. Then I decided to try also to create grid columns dynamically. So I set the AutoGenerateColumns property to false. I changed the code, so it would create some columns like this
private void Page_Load(object sender, System.EventArgs e
AddSomeColumnsToGrid();
if (!IsPostBack
GridBind()
Now when I load the page for the 1st time, everything is OK. When I want to go to another page grid mystically disappears. I tried to debug the page setting breakpoint inside the PageChanged event and I never got there
Being desperate I tried everything possible then I came to something like this
private void Page_Load(object sender, System.EventArgs e
AddSomeColumnsToGrid();
//if (!IsPostBack
GridBind()
and it worked. But now I am creating dataset 2 times in postback (supposing it's the page changed event)
Am I doing anything wrong? Because I really don't know how to solve this problem. Any helps would be very appreciated.
I have a DataGrid in the page, nothing special about it, only it connects datasource programatically and it supports paging.y. So the code is something like this
private void Page_Load(object sender, System.EventArgs e
if (!IsPostBack
GridBind()
private void GridBind(
myGrid..DataSource = GetSomeDataSource()
myGrid.DataBind()
private void PageChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e
myGrid.CurrentPageIndex = e.NewPageIndex
BindData()
This worked perfectly OK. Then I decided to try also to create grid columns dynamically. So I set the AutoGenerateColumns property to false. I changed the code, so it would create some columns like this
private void Page_Load(object sender, System.EventArgs e
AddSomeColumnsToGrid();
if (!IsPostBack
GridBind()
Now when I load the page for the 1st time, everything is OK. When I want to go to another page grid mystically disappears. I tried to debug the page setting breakpoint inside the PageChanged event and I never got there
Being desperate I tried everything possible then I came to something like this
private void Page_Load(object sender, System.EventArgs e
AddSomeColumnsToGrid();
//if (!IsPostBack
GridBind()
and it worked. But now I am creating dataset 2 times in postback (supposing it's the page changed event)
Am I doing anything wrong? Because I really don't know how to solve this problem. Any helps would be very appreciated.