473,387 Members | 1,582 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

View state and Datagrid images

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);

}

}
Apr 10 '06 #1
1 1607
I tried rebinding the grid in the page load event with or without a postback
but then it loses the values which have been entered into a text box column
before the postback.

Is there no way to keep the images being displayed on the grid when the page
is reloaded? All the other information is held in the view state and
displayed correctly. Surely there must be a solution to this somewhere....?

Please, help!!!
"John" <jh******@msn.com> wrote in message
news:eo**************@TK2MSFTNGP02.phx.gbl...
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!="&nbsp;")

{

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);

}

}

Apr 12 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jesper DK | last post by:
Hi, I have docked a tree view to the left on a form. When I start to populate this tree view with nodes, a horizontal scroll box appears in the bottom of the tree view even though thee tree...
2
by: sunstarwu | last post by:
Hi, I am having difficultly being able to view certain Columns and rows via a DropDownList. Everytime I load my webpage.aspx it just shows empty drop down menus. I have no problem showing all...
4
by: Souri Challa | last post by:
Hello All, When a datagrid in a web form is getting re populated from view state on post back, it is firing the datagrid Item Created event but the DataGridItem(e.Item.DataItem is null) in the...
1
by: Philip Poole | last post by:
Hello everyone, I have been using controls for the first time and with the controls I have been using the view state. I have now get a web page aprt from when I press F5 on the first screen...
6
by: Bala | last post by:
Hi all, In my page load i am loading nearly 5 diffferent arrays. each array having nearly 1000 items. after that i am doing some calculation add some list into datagrid using that array values....
12
by: Raed Sawalha | last post by:
I have the following table which i can not switcha to design view error message said Could not open in Design view. Quote values differently inside a '<% ...."value"... %>' block. and the...
1
by: Ken Varn | last post by:
I have a problem where my DataGrid would not maintain the ViewState of my databound rows. I finally narrowed down the problem. If my first column is a template column, the view state for the...
2
by: CK | last post by:
Hi All, I am making a filter for a web page datagrid. I have the inner workings of the filter doing what I need it to do. What I am trying to accomplish now is to somehow retain the state of the...
0
by: rupalirane07 | last post by:
Both grids displays fine. But the problem is only parent datagrid sorting works fine but when i clik on child datagrid for sorting it gives me error: NullReferenceException error Any...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.