GlobaLevel
asked on
asp.net - handle an event in sql
do I have the session varaible formtted correctly here?
DefaultValue="Session('rpt Shoereport ing')"
also I need to control what parameter is sent to the sql server db...with the below code...is that correct?
===================
<asp:SqlDataSource ID="dsItemsDetail" runat="server" OnInserted="ObjectDataSour ceStatusEv entHandler " ConnectionString="<%$ ConnectionStrings:abcCompC onnectionS tring %>"
SelectCommandType="StoredP rocedure" SelectCommand="rptShoeRepo rting">
<SelectParameters>
<asp:Parameter Name="RptType" Type="Int32" DefaultValue="Session('rpt shoereport ing')" />
<asp:Parameter Name="RptSubType" Type="string" />
<asp:Parameter Name="Userid" Type="string" />
</SelectParameters>
</asp:SqlDataSource>
-------
Protected Overrides Sub OnInit(ByVal e As EventArgs)
MyBase.OnInit(e)
odsOrders.Selected += New ObjectDataSourceStatusEven tHandler(o dsOrders_S elected)
odsCustomersList.Selected += New ObjectDataSourceStatusEven tHandler(A ddressOf odsCustomersList_Selected)
End Sub
Private Sub odsCustomersList_Selected( ByVal sender As Object, ByVal e As ObjectDataSourceStatusEven tArgs)
'notice that this datasource returns a DataView
lblCount1.Text = "Total Record count in the dropdownlist above= " & DirectCast(e.ReturnValue, DataView).Count.ToString()
End Sub
DefaultValue="Session('rpt
also I need to control what parameter is sent to the sql server db...with the below code...is that correct?
===================
<asp:SqlDataSource ID="dsItemsDetail" runat="server" OnInserted="ObjectDataSour
SelectCommandType="StoredP
<SelectParameters>
<asp:Parameter Name="RptType" Type="Int32" DefaultValue="Session('rpt
<asp:Parameter Name="RptSubType" Type="string" />
<asp:Parameter Name="Userid" Type="string" />
</SelectParameters>
</asp:SqlDataSource>
-------
Protected Overrides Sub OnInit(ByVal e As EventArgs)
MyBase.OnInit(e)
odsOrders.Selected += New ObjectDataSourceStatusEven
odsCustomersList.Selected += New ObjectDataSourceStatusEven
End Sub
Private Sub odsCustomersList_Selected(
'notice that this datasource returns a DataView
lblCount1.Text = "Total Record count in the dropdownlist above= " & DirectCast(e.ReturnValue, DataView).Count.ToString()
End Sub
For the first question, it should be;
DefaultValue=Session('rptS hoereporti ng')
As to the second question, I'd think it should be:
<asp:Parameter Name="RptType" Type="Int32" DefaultValue=Session('rpts hoereporti ng') />.. but I'm not authoritative on that.
DefaultValue=Session('rptS
As to the second question, I'd think it should be:
<asp:Parameter Name="RptType" Type="Int32" DefaultValue=Session('rpts
ASKER
I tried your way, but I get an error, the input string is not a correct format
Hmmm. How about:
<asp:Parameter Name='RptType' Type='Int32' DefaultValue=' & Session("rptshoereporting" ) & ' />
<asp:Parameter Name='RptType' Type='Int32' DefaultValue=' & Session("rptshoereporting"
ASKER
that didnt work...either..
As I said, use a control parameter to supply the selected value from dropdownlist to the sqldatasource
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.controlparameter.aspx
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.controlparameter.aspx
Ugh, sorry. Try this:
<asp:Parameter Name='RptType' Type='Int32' DefaultValue='<% =Session("rptshoereporting ") %>' />
<asp:Parameter Name='RptType' Type='Int32' DefaultValue='<% =Session("rptshoereporting
ASKER
if I use a controlparameter ....if the dropDownlist ="all" then send the parameter "7" to the sql
its not really apart of the DLL as its not apart of the dataset ..
publkic sub page_load...
...
ddlUser.DataSource = dv
ddlUser.DataBind()
ddlUser.Items.Insert(0, New ListItem("ALL", "-1"))
..
end sub
<asp:SqlDataSource ID="dsItemsDetail" runat="server" ConnectionString="<%$ ConnectionStrings:abccompC onnectionS tring %>"
SelectCommandType="StoredP rocedure" SelectCommand="rptshoeRepo rting">
<SelectParameters>
<asp:controlparameter name="RptType" Type="Int32" controlid="ddluser" propertyname="All" DefaultValue="7" />
<asp:Parameter Name="RptType" Type="Int32" DefaultValue="4" />
<asp:Parameter Name="RptSubType" Type="string" />
<asp:Parameter Name="Userid" Type="string" />
</SelectParameters>
</asp:SqlDataSource>
---
havent used the control paramter all that much..see how RptType is in there twice?
its not really apart of the DLL as its not apart of the dataset ..
publkic sub page_load...
...
ddlUser.DataSource = dv
ddlUser.DataBind()
ddlUser.Items.Insert(0, New ListItem("ALL", "-1"))
..
end sub
<asp:SqlDataSource ID="dsItemsDetail" runat="server" ConnectionString="<%$ ConnectionStrings:abccompC
SelectCommandType="StoredP
<SelectParameters>
<asp:controlparameter name="RptType" Type="Int32" controlid="ddluser" propertyname="All" DefaultValue="7" />
<asp:Parameter Name="RptType" Type="Int32" DefaultValue="4" />
<asp:Parameter Name="RptSubType" Type="string" />
<asp:Parameter Name="Userid" Type="string" />
</SelectParameters>
</asp:SqlDataSource>
---
havent used the control paramter all that much..see how RptType is in there twice?
Server Error in '/' Application.
--------------------------------------------------------------------------------
DataBinding: 'System.Web.UI.WebControls.DropDownList' does not contain a property with the name 'All'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: DataBinding: 'System.Web.UI.WebControls.DropDownList' does not contain a property with the name 'All'.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
>propertyname="All"
There is no All property on drop down list. Use
propertyname="SelectedValu e"
There is no All property on drop down list. Use
propertyname="SelectedValu
ASKER
okay now I get the error:
Parameter '@RptType' was supplied multiple times.
Parameter '@RptType' was supplied multiple times.
Do you have any other code that sets its value?
ASKER
yeah this in bold is also setting its value....it was pasted in above too...
<asp:SqlDataSource ID="dsItemsDetail" runat="server" ConnectionString="<%$ ConnectionStrings:abccompC onnectionS tring %>"
SelectCommandType="StoredP rocedure" SelectCommand="rptshoeRepo rting">
<SelectParameters>
<asp:controlparameter name="RptType" Type="Int32" controlid="ddluser" propertyname="All" DefaultValue="7" />
<asp:Parameter Name="RptType" Type="Int32" DefaultValue="4" />
<asp:Parameter Name="RptSubType" Type="string" />
<asp:Parameter Name="Userid" Type="string" />
</SelectParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="dsItemsDetail" runat="server" ConnectionString="<%$ ConnectionStrings:abccompC
SelectCommandType="StoredP
<SelectParameters>
<asp:controlparameter name="RptType" Type="Int32" controlid="ddluser" propertyname="All" DefaultValue="7" />
<asp:Parameter Name="RptType" Type="Int32" DefaultValue="4" />
<asp:Parameter Name="RptSubType" Type="string" />
<asp:Parameter Name="Userid" Type="string" />
</SelectParameters>
</asp:SqlDataSource>
ASKER
so I get a dropdownlist on page load:
All
John Smith
Eddie James
Mary Connor
if they choose 'All' then the value of the parameter RptTYpe needs to be changed to "7"
If they choose anything else than 'All', the value of the paramter RptType needs to be "4"
All
John Smith
Eddie James
Mary Connor
if they choose 'All' then the value of the parameter RptTYpe needs to be changed to "7"
If they choose anything else than 'All', the value of the paramter RptType needs to be "4"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Protected Overrides Sub OnInit(ByVal e As EventArgs)
MyBase.OnInit(e)
odsOrders.Selected += New ObjectDataSourceStatusEven
odsCustomerList.Selected += New ObjectDataSourceStatusEven
End Sub
Private Sub odsCustomersList_Selected(
'notice that this datasource returns a DataView
If ddlUser.Text = "ALL" Then
Session("rptshoereporting"
End If
If ddlUser.Text <> "ALL" Then
Session("rptshoereporting"
End If
End Sub