Getting undefined value while using view state in Web Form Designer generated code

hi,

    i am trying to get the drop down list selected value in Web Form Designer generated code,when i am trying it with view state i am getting some undefined value.

please help me regarding this.. 

i am trying with the following code. 

      

refinery =  ddRefineries.SelectedRefinery; 

ViewState.Add("ref1",refinery);
 

#region Web Form Designer generated code
        override protected void OnInit(EventArgs e)
        {
            //
            // CODEGEN: This call is required by the ASP.NET Web Form Designer.
            //
            _sortHelper = new SortHelper(dgMapping, this);
            _sortHelper.AttachEvents();
            InitializeComponent();
            MyEvents();
           
            Refinery re = (Refinery)ViewState["ref1"];
            base.OnInit(e);

 

 

regards

roopesh 

0
roopesh
3/23/2007 6:44:02 AM
asp.net.state-management 8807 articles. 0 followers. Follow

3 Replies
1018 Views

Similar Articles

[PageSpeed] 14

Try in this way

To Assign Value.

ViewState[

"ref1"] = refinery;

 

To retrive value

 Refinery re = (Refinery)ViewState["ref1"];

 


Ashok Raja
www.iGold.in

Don't forget to click "Mark as Answer" on the post that helped you.
This credits that member, earns you a point and marks your thread as Resolved.
0
AshokRaja
3/23/2007 7:03:05 AM

thanks for your reply

 

even this is not working,still i am getting the same undefined value  

0
roopesh
3/23/2007 7:08:04 AM
I have not noticed the place where you have called the viewstate. You have called in OnInit. Viewstate won't be available at that stage. Try to access the viewstate on PageLoad
Ashok Raja
www.iGold.in

Don't forget to click "Mark as Answer" on the post that helped you.
This credits that member, earns you a point and marks your thread as Resolved.
0
AshokRaja
3/23/2007 10:53:42 AM
Reply:

Similar Artilces:

superreview granted: [Bug 388387] [FIX] Avoid generating state keys for form restoration if there's no state to get
Jonas Sicking <jonas@sicking.cc> has granted Boris Zbarsky <bzbarsky@mit.edu>'s request for superreview: Bug 388387: [FIX]Avoid generating state keys for form restoration if there's no state to get https://bugzilla.mozilla.org/show_bug.cgi?id=388387 Attachment 272591: Like so https://bugzilla.mozilla.org/attachment.cgi?id=272591&action=edit ...

superreview requested: [Bug 388387] [FIX] Avoid generating state keys for form restoration if there's no state to get
Boris Zbarsky <bzbarsky@mit.edu> has asked Jonas Sicking <jonas@sicking.cc> for superreview: Bug 388387: [FIX]Avoid generating state keys for form restoration if there's no state to get https://bugzilla.mozilla.org/show_bug.cgi?id=388387 Attachment 272591: Like so https://bugzilla.mozilla.org/attachment.cgi?id=272591&action=edit ------- Additional Comments from Boris Zbarsky <bzbarsky@mit.edu> This is a bit of a hack.... Right now, during initial load of a page, we generate form state keys for form controls, even though there is no state to get. I'm...

I am using an HttpHandler with PageMethods.I get a javascript error on stating: PageMethods is undefined. But same code in an .aspx file will be run successfully.
I am using an HttpHandler with PageMethods.I get a javascript error on stating: PageMethods is undefined. But same code in an .aspx file will be run successfully. why?thanks.   please put your code here. after looking your code i will give you suggestionplease mark as answer if this is the solutionrohit gandhi Hi zjx Maybe other threads can help you, look at: http://www.google.ch/search?hl=de&q=PageMethods+is+undefined&meta=--Microsoft MVP - Visual Developer ASP / ASP.NET- http://www.aspnetzone.de/blogs/peterbucher/ - Auf den Spuren von .NET Hi rohit gandhi, ...

State Management in Web Forms
This article discusses the ways in which the state management can be handled in web forms. State management can be done either on client side or server side as explained below. Author-Jalajakshi Venkataramana http://www.dotnetbips.com/displayarticle.aspx?id=247...

How to get the HREF value of the Anchor tag in a web page using the web browser control in vb.net
Hi Friends,               i have a webserver control in my application.i load the web browser control on a button click using the below code Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click                AxWebBrowser1.Navigate("http://www.rateitall.com/i-322335-.aspx", False) End sub once the page is loaded in the browser i want the <a> HREF value in that page.For example if that page has ...

Web Form Designer Generated Code?
HiWe are extending an ASP.NET/VB application that was earlier developed using VS.NET ... while we are using NotePad/CommandLine.There's the following piece of code in each ASPX.VB page:#Region " Web Form Designer Generated Code "         'This call is required by the Web Form Designer.        <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()         End Sub        Protected WithEvents dgDrafts As System.Web.UI.WebContro...

Web form Designer generated code???
where is this code in vs 2005 and vs 2008 ? secondly leading form the question above i need to handle the prerender for my web page how do i do this in 2005 and 2008??????This above all: to thine own self be true.William shakespeare, Hamlet the generated code from the designer in in the source view. in the soltuion explorer with the list of all the file in the project, right click the .aspx page and select "view code". or select source view from underneath the design aread.  To hand the prerender event you need to make an event for Page_PreRender. Please remember to click...

Web Form Designer Generated Code
Hello All, In VS2003 there's a Region called Web Form Designer Generated Code. On this region, the web componentes are described so the code can have access to it. So, is there a similar region in VS2005 .aspx files? I coudn't see it ... The code is generated automatically, but not visible to you. If you use the Web Application Projects, a separate designer file is generated. HTH,RyanRyan OlshanASPInsider | Microsoft MVP, ASP.NEThttp://ryanolshan.comHow to ask a question...

Web Form Designer Generated Code
I am upgrading an application from asp.net 1.1 to asp.net 2.  The use of partial classes instead of the old code with all the declarations in it inside the old Web Form Designer Generated Code regions is causing a big problem with my code.  Is there a way in which to switch this functionality back to the old VS2003 way but keep it working in VS2005?   thanks   Twisted any ideas on how to get asp.net 2's code behind files to act like asp.net 1.1?  I.e. no partial classes, one code behind file and the ability to specify declared controls in the code? T...

Web Form Designer Generated code
Hi I have a ASP.Net 1.1 website with VB as code behind and the aspx pages inherit from certain business objects which in turn inherit from the System.Web.UI.Page class. In the business object, they have go the declaration for a couple of third party controls present in all the pages. The problem is that every time, I switch to design mode for the pages, Visual Studio inserts a property declaration for those controls present in the page and now it is duplicated. Is there a way I can trick Visual Studio not to insert declarations for all those controls which are already defined in any...

superreview granted: [Bug 285285] Add SINGLE_LINE state to single line text inputbox : [Attachment 176741] Clean up form control and text field state code, add single line extended state support
Henry Jia <Henry.Jia@sun.com> has granted Louie Zhao <Louie.Zhao@sun.com>'s request for superreview: Bug 285285: Add SINGLE_LINE state to single line text inputbox https://bugzilla.mozilla.org/show_bug.cgi?id=285285 Attachment 176741: Clean up form control and text field state code, add single line extended state support https://bugzilla.mozilla.org/attachment.cgi?id=176741&action=edit ...

superreview requested: [Bug 285285] Add SINGLE_LINE state to single line text inputbox : [Attachment 176741] Clean up form control and text field state code, add single line extended state support
Louie Zhao <Louie.Zhao@sun.com> has asked Henry Jia <Henry.Jia@sun.com> for superreview: Bug 285285: Add SINGLE_LINE state to single line text inputbox https://bugzilla.mozilla.org/show_bug.cgi?id=285285 Attachment 176741: Clean up form control and text field state code, add single line extended state support https://bugzilla.mozilla.org/attachment.cgi?id=176741&action=edit ...

Session state management using web services.
 Hi all ,i am working of a hospital management system which we desided to develop using atlas frame work. we have created the application main to sections using atlas script call back architecture. we are using scripts to pack the user entered data to the web service and in that web service we are entering the data in to the database.all this happening with out a post back of the page.now comes the problem. we are not being able to handle the user session properties. we came to know that we cant access session variables in web services. we are in a trap now. how we can manage the sessio...

Using View State in a Web Service file
Hi,  I would like to use the view state with a web method in an asmx file but I get the 'ViewState' is not declared error.  I would be glad if anyone could provide help. Thanks.   From your description, you're consuming an ASP.NET webservice in an  ASP.NET  web application project. The webservice methods will return some custom  class objects(which is marked as serializable at server-side code) and you  will store them in ASP.NET page's viewstate in web application. However,  you found the client custom classes in the gen...