[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 171
  • Last Modified:

Vb.net - need to change session value of a SQL object datasouce at runtime

Once the user hits submit I needto change the value of a session variable beforeit getsto the object datasourve control to process ...isn't that done inside the pre_init method?
0
GlobaLevel
Asked:
GlobaLevel
  • 4
  • 3
1 Solution
 
CodeCruiserCommented:
Why not using one of the ObjectDataSource events such as inserting, updating, deleting. This happens before the operation (Insert, update, delete)

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdatasource.inserted.aspx
0
 
GlobaLevelAuthor Commented:
So this event method will allow me to change the parameter that gets fed into the stored procedure based on the value of the dropdownlist that the user selects.
0
 
CodeCruiserCommented:
Yes.
0
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
GlobaLevelAuthor Commented:
CodeCruiser....


im getting an error--Input String is not in a correct format...none of these are working...
     <asp:Parameter Name="RptType" Type="Int32" DefaultValue="session('rptShoereporting')" />
     <asp:Parameter Name="RptType" Type="Int32" DefaultValue=session("rptShoereporting") />
     <asp:Parameter Name="RptType" Type="Int32" DefaultValue="<%session('rptShoereporting') %>" />


<asp:SqlDataSource ID="dsItemsDetail" runat="server"   ConnectionString="<%$ ConnectionStrings:abcCompConnectionString %>"
                    SelectCommandType="StoredProcedure" SelectCommand="rptManagementReporting">
                    <SelectParameters>
                        <asp:Parameter Name="RptType" Type="Int32" DefaultValue="<%session('rptShoereporting') %>" />
                        <asp:Parameter Name="RptSubType" Type="string" />
                        <asp:Parameter Name="Userid" Type="string" />
                    </SelectParameters>
                </asp:SqlDataSource>
0
 
CodeCruiserCommented:
You r not using the events to set the values.
0
 
GlobaLevelAuthor Commented:
CodeCrusier....all I am trying to do is overload the paramenter 'rpttype' to capture the value that the user selects from a dropdownlist at runtime....if they select 'ALL' from the DDL then the parameter should be 6, if its not = 'ALL' then 4...the code below runs ..but its not running data to the back side did it miss providing the value to the sqldatasource before it ran to the database?

Ive got this..
  Private Sub odsCustomersList_Selected(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ObjectDataSourceStatusEventArgs)
        'notice that this datasource returns a DataView

        If ddlUser.Text = "ALL" Then
            Session("rptmanagementreporting") = "6"
            dsItemsDetail.InsertParameters("RptType").DefaultValue = 6
        End If

        If ddlUser.Text <> "ALL" Then
            Session("rptmanagementreporting") = "4"
            dsItemsDetail.InsertParameters("RptType").DefaultValue = 4
        End If


    End Sub
0
 
CodeCruiserCommented:
As I mentioned in your other questions, use a control parameter.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now