.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Persist Images in Gridview after postback

Posted By:      Posted Date: October 06, 2010    Points: 0   Category :ASP.Net

Hello friends, I have a grid view whose 1st column is Image Field. Now I assign 1 out of 4 images to each row at runtime. I have this gridview in ajax updatepanel. Now how can i persist the images in the first column after a postback.

View Complete Post

More Related Resource Links

Maintain HTML Radio Button Selection Inside GridView After Postback

Long time ago I wrote an article about getting the value of the selected RadioButtons inside the GridView control. The code did not addresssed the postback issue which means that the selected radio button was cleared after the postback occurs.

Images to conditionally appear in Gridview

Howdy all!- I've got this gridview with a column labeled "Client Comment" that displays a clickable little icon when there is a client comment in the database.  The problem is the icon is appearing whether or not there is data in the DB  (except I don' t think it does when the DB value is null.)   How can I make it so the icon only appears if there is a comment in that database field?  With code behind (if so VB) or in the tag?    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="clientID"> <Columns> <asp:BoundField DataField="clientFirstName" HeaderText="First Name" /> <asp:BoundField DataField="clientLastName" HeaderText="Last Name" /> <asp:HyperLinkField HeaderText="Client Comment" DataNavigateUrlFields="clientID" DataNavigateUrlFormatString="~/ClientInfo.aspx?ID={0}" DataTextField="clientComments" Da

GridView Paging Postback

I have to DataGrids on same page and they both got paging on that cause postback. Now on every single post back i want to find which DataGrid Paging caused the post back this time... Any Ideas?

1st PostBack only: SelectedIndexChanged events fire AND GridView & ReadOnly controls disappear

On initial load of the page, everything is visible & runs correct. On the first PostBack fired by any one of my DDLs, RadioBtns, LinkBtns that have the AutoPostBack=true property, then ddlPriority_SelectedIndexChanged & ddlPendUserReqType_SelectedIndexChanged events always fire (and only from these DDLs, the others don't fire inappropriately), even when neither of those controls had been selected. Then my GridView gridPendRoles disappears, unless a DataSource & DataBind() is forced. Any ReadOnly controls (lblTicketID, txbxInsertTicketDate, lblPendUserID) will also loose their data/text in the first PostBack. However, every PostBack following will not inappropriately fire events. And as long as a DataSource was set & DataBind() called a 2nd time at any time during any PostBack, the GridView will stay visible with correct data displayed. Again, as long as the ReadOnly controls have their data/text set a 2nd time during any PostBack, they too will retain their data/text for every following PostBack. I've tried debugging with Trace on & walked thru everything very thoroughly, but still cannot catch any reasons why this would occur. And since I am using the Delete & Edit command linkBtns in my GridView, I can't just force a DataSource & DataBind() on every PostBack, or I would loose those Row

Gridview attribute changed by javascript is lost on postback

I have a gridview control that extends the default gridview.  I have added an attribute called "hiddenSelectedValues" to to the gridview during the "PreRender" event and I have a private variable that points to the value of that attribute. I have some javascript code that modifies the value of this attribute based on the user checking or unchecking checkboxes in the grid.  I have confirmed that the javascript is indeed modifying the value of the "hiddenSelectedValues" attribute by using Firebug to see the change as it happens. However, once a postback occurs, the grid looses the updated value of this attribute and I am unable to reference get the updated value on the server side. How do I keep the value of an attribute changed by javascript on postback?

gridview viewstate (size around 1.75Mb on each postback) very serious problem

i am developing a a web application of a general store where the operator has to enter the things what cutomer has purchased..like daily useage item,or anyhing ..so i have form in which i first ask how much item u wanna regsiter...(if he has 20-30 number of items then operator will eneter 20-30 then in gridview 20-30 item are opened...with bind dropdownbox containing name of item ,then textboxs containing mrp,value,stock avail of that item .here is the link for demo... http://iconsoftech.com/mahajan/grid/gridview_test.aspxproblem is suppose the operator enter the value above 20.. then then viewstate size id about 1.50Mb thats too heavey please suggest me solution for this problem..<%@ Page Language="C#" AutoEventWireup="true" CodeFile="gridview_test.aspx.cs" Inherits="gridview_test" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <div> <asp:Label ID="Label4" runat="server" Text="Enter No. Of Products"></asp:Label&g

gridview images


Good morning.

I have a hyperlink column in my gridview, when the user clicks then link 'edit' on a row it calls up all of the information for them to change. It's all working nicely, however I would like to change the word edit to an icon but I can't work out how to do it. I've experimented with templatefields and buttonfields.

Any help would be greatly appreciated.


Thanks in advance.



How to Make a custom property or a page persist across postback



As the title suggests, I have an object to hold some specific state information in my web application - I pass it back & forward between pages by making it a property of a basepage which works fine, but I lose it on postback.

Is there any way to persist this property without manually adding & reading it again from viewstate?



how to persist a class object when page PostBack


i have created a user control UserControl.ascx, in Code behind file of UserControl.ascx i have created an object of a class MyClass.cs,
if(!Page.IsPostback) {
objMyClass= new MyClass();
but when i click on button of UserControl.ascx page and try to access objMyClass object then it set as null, so how to persist MyClass object when page PostBack, i wanted to keep object persist till the user access the page, when user goes out of this page then object should distroy?

To keep the object persist, i have used ViewState

So i have made MyClass Serializable and
i have used ViewState to keep my objet persist, but it give the error
like : UserControl is not marked as serializable.

so i have made my UserControl as Serializable, but the problem is still coming.

One more thing is that MyClass is also resposnsible to create some other class object also.

Can any one suggest me correct solution?

Problem i am getting when i try to PersisObject On UserControl

[SerializationException: Type 'ASP.common_grid_UserControl_ascx' in Assembly 'App_Web_44142fbl, Version=, Culture=neutral, PublicKeyToken=null' is not marked as serializable.] System.Runtime.Serialization.FormatterServices.InternalGetSeri

Gridview CheckBox Persist in Paging


I Use a Gridview which Contains Lots OF Records with Paging...

 I have a checkBox Column ,i want to persist state of Checked Checkboxes while Moving From One Page To Another.

Example:-Suppose a Check a Checkbox on First Page 6th Row and Move to 2nd Page and Check 10th Row,and Then when i naviagte back to 1st Page i want to Show the 6th Row Checked in First Page and Viceversa... 


Gridview CheckBox Persist in Paging


Related to this thread: Gridview CheckBox Persist in Paging

Is there any other option than ViewState or Session to save the datatable ? 

Images in GridView


I have got a column (image field) and i populate 4 images in all the rows according to some condition. last column is having link to other page. I am using RowCommand to get the index of the row, here I also need to know which image is in first column. How can i do this.

Is it possible to sort rows according to the images in first column?

Gridview in postback no showing up


Hey All, 

I am trying to create a form that displays a dropdown and a password. The dropdown will act as the login for the password. If the password is correct the dropdown should be the variable for a gridview that should be visible? Can someone look at my code and see where I may be going wrong or any hints?

ASP Code

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="RtlFormStoreSubmittedForms.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Forms Submitted</title>
    <style type="text/css">
            height: 676px;
    <form id="form1" runat="server">

    <asp:SqlDataSource ID="SqlDSStoreNum" runat="server" 
        ConnectionString="<%$ ConnectionStrings:samConnectionString %>" 
        SelectCommand="select Store, Store +' - '+Store_name as StoreName, replace(id_cont,'01','')as id_cont from stores where a

losing gridview row value on postback


i have a global field called hotelId. i then have this piece of code that gets a value from gridview row:

        protected void gvHotel_SelectedIndexChanged(object sender, EventArgs e)
            if (Page.IsPostBack)
                int hotelId = (int)gvHotel.SelectedDataKey.Value;

the local variable is assigned to my global one, which gets passed to my method along with other variables. while stepping through i can see the value is set, but when i hit the submit button variabl is passed to another method except my hoteId. it gets lost...

What must be done to persist RSS Feeds on web pages after a postback?


 Hello Community

    If I put  jpg  images on a Mulitpage web control connected to a TabStrip on a web page that also contains a Calendar control
and I can click on the Calendar control the jpg images on the Mulitpage web control will remain on the web page even if it postbacks.

    But if I replace the jpg images on the Multipage web control with  RSS Feed links  and then click on the Calendar control the RSS Feed links on the Mulitpage
web control will disappear.  Below are the RSS Feed Links in the Multipage web control and the Calendar control :

          <asp:Table ID="MYTable" runat="server"
                BorderStyle="None"  >
                <asp:TableCell Font-Underline="True">

open Images on Thumbnail click without server postback


I have a webpage which contains a  table to display full images. There are thumb nail images on clicking which the table would show(or hide) the respective full image. All the images are loaded and set to be hidden at the time of pageload. The requirement is when the thumbnail is clicked, full image is loaded without a server post back. Can someone tell me how to achieve this?

open Images on Thumbnail click without server postback


I have a webpage which contains a  table to display full images. There are thumb nail images on clicking which the table would show(or hide) the respective full image. All the images are loaded and set to be hidden at the time of pageload. The requirement is when the thumbnail is clicked, full image is loaded without a server post back. Can someone tell me how to achieve this?

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend