So, here’s the scenario:
I have a page in my asp.net c# based website, which displays data dynamically after taking the request from query strings.
For example:
Brand=HTC&model=Wildfire
Now, in this page I want to display all the deals available in each network separately.
So, on the first pageload, I retrieve the data from the tables of each network that has the requested handset in a deal, store it as a datatable in the cache.
I have a datalist for displaying the imagebuttons of the networks that have the deals of that handset. The user will click on the imagebutton of a network to view the deals of that network.
To display the deals, I am using a gridview which retrieves its datasource from the cache. Also, I have provided filtering of the rows through dropdowns in each columns’ header of the gridview.
All this is inside an updatepanel.
Everything’s working fine.
The Problem:
I want that whenever the user clicks a network’s image button, an image should appear above the gridview, containing the logo of that network.
Things that I have tried:
I am storing the networkname in the cache(which also required for filtering the gridview), whenever an imagebutton is clicked. Then, on pageload, I’m doing this:
if(ScriptManager1.IsInAsyncPostBack)
{
Image img = new Image();
img.ImageUrl = "images/" + Cache["network"] + "_logo.jpg";
nw_image.Controls.Clear();
nw_image.Controls.Add(img);
}
where, nw_image is a tablecell which i’m using to display the selected network logo.
and also I’ve saved the network logos in the images folder as: ‘network’_logo.jpg
eg: 3_logo.jpg, orange_logo.jpg
The result of this is that when I click a new image button, the image that is displayed is that of the previous network, i.e. the cache is always one postback late.
Please Help!
Thanks!
At last I’ve got it to work.
I’ve now put a static image without any properties except
id = "net_img",runat = "server"andEnableViewState = "true".And instead of taking the network name from the cache, I’m changing the image in the click event of the ImageButton according to the Imagebutton that is clicked.
And it works now! 🙂