Binding ObjectDataSource.SelectParameter to ViewState instead of Control

Last post 09-28-2007 9:51 AM by smithersgs. 1 replies.

Sort Posts:

  • Binding ObjectDataSource.SelectParameter to ViewState instead of Control

    05-13-2006, 8:26 PM
    • Member
      85 point Member
    • EletroClick
    • Member since 11-11-2005, 1:32 AM
    • Posts 17

    Hello, Friends

    I'm binding some data in my GridView using ObjectDataSouce. I need too, specify some SelectParameters what are stored in ViewState, but in the "Parameter Collection Editor Dialog", the "Parameter Source" option shows only: Cookie, Control, Form, Profile, QueryString, Session

    I wish bind to some value in ViewState. How not appears the option "ViewState", I need place my values in some HiddenField control to bind...

    Someone knows how I do to bind to ViewState?

    Regards

    Fabio

     

  • Re: Binding ObjectDataSource.SelectParameter to ViewState instead of Control

    09-28-2007, 9:51 AM
    • Member
      25 point Member
    • smithersgs
    • Member since 05-21-2007, 4:49 PM
    • Posts 109

    Good point, Fabio! I have the same issue. I am not sure you found a solution, but amybe you found a workaroud at lesat.

    Here are my workarounds.

    1. Use _selecting event of the datasource

       protected void ObjectDataSource1_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
        {
            e.Command.Parameters["@paraname"].Value = ViewState["whatever"];  
        }

    If you don't like the above...

    2. Use a hidden (invisible) control such as a lable, then set its parameter source to that control.

    J

Page 1 of 1 (2 items)
Microsoft Communities