J
John
I am using the ItemDataBound event on the datagrid to place relevant images
in the grid. However, when I press any button on the form which fires a
postback the state of the grid is kept but the images no longer appear as
the ItemDataBound event is no longer fired. The solution to this is to
refresh the grid with the original data using the page load event after
postback but then it loses the data that the user has already typed into the
grid pre-postback due to the grid being refreshed.
Anyone have any idea how to solve this?
My Code :
if (e.Item.Cells[7].Text!="Stock" & e.Item.Cells[7].Text!=" ")
{
if (Convert.ToInt32(e.Item.Cells[7].Text)<=0)
{
System.Web.UI.WebControls.Image imgGridImage =
(System.Web.UI.WebControls.Image)e.Item.Cells[5].Controls[1];
imgGridImage.ImageUrl="../images/OutStock.gif";
e.Item.Cells[5].Controls.Add(imgGridImage);
}
else
{
System.Web.UI.WebControls.Image imgGridImage =
(System.Web.UI.WebControls.Image)e.Item.Cells[5].Controls[1];
imgGridImage.ImageUrl="../images/InStock.gif";
e.Item.Cells[5].Controls.Add(imgGridImage);
}
}
in the grid. However, when I press any button on the form which fires a
postback the state of the grid is kept but the images no longer appear as
the ItemDataBound event is no longer fired. The solution to this is to
refresh the grid with the original data using the page load event after
postback but then it loses the data that the user has already typed into the
grid pre-postback due to the grid being refreshed.
Anyone have any idea how to solve this?
My Code :
if (e.Item.Cells[7].Text!="Stock" & e.Item.Cells[7].Text!=" ")
{
if (Convert.ToInt32(e.Item.Cells[7].Text)<=0)
{
System.Web.UI.WebControls.Image imgGridImage =
(System.Web.UI.WebControls.Image)e.Item.Cells[5].Controls[1];
imgGridImage.ImageUrl="../images/OutStock.gif";
e.Item.Cells[5].Controls.Add(imgGridImage);
}
else
{
System.Web.UI.WebControls.Image imgGridImage =
(System.Web.UI.WebControls.Image)e.Item.Cells[5].Controls[1];
imgGridImage.ImageUrl="../images/InStock.gif";
e.Item.Cells[5].Controls.Add(imgGridImage);
}
}