GlobaLevel
asked on
asp.net - vb.net Input string was not in a correct format.
it errors at where the default value = the session varaible
<asp:SqlDataSource ID="dsItemsDetail" runat="server" ConnectionString="<%$ ConnectionStrings:abcCompC
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>
I have also tried, but not working:
<asp:Parameter Name="RptType" Type="Int32" DefaultValue=Session('rptS
You need to use a SessionParameter vs. a regular Parameter. See the code example here: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.sessionparameter.aspx
ASKER
kaufmed...
can you give me some kind of example....that link doesnt really provide one...
does it need to use:
dsItemsDetail.InsertParame ters("RptT ype").Defa ultValue = 6
also in your example do I need to create another class with this?
'Declaration
Public Class SessionParameter _
Inherits Parameter
>>>>not sure how to imp0lement that....thanks!
can you give me some kind of example....that link doesnt really provide one...
does it need to use:
dsItemsDetail.InsertParame
also in your example do I need to create another class with this?
'Declaration
Public Class SessionParameter _
Inherits Parameter
>>>>not sure how to imp0lement that....thanks!
that link doesnt really provide one...How far did you scroll down?
<%@ Page language="C#"%>
<!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>ASP.NET Example</title>
</head>
<body>
<form id="Form1" method="post" runat="server">
<p>Show My Orders:</p>
<asp:SqlDataSource
id="OdbcDataSource1"
runat="server"
ProviderName="System.Data.Odbc"
ConnectionString="dsn=MyOdbcDsn;"
SelectCommand="SELECT OrderId, CustomerId, OrderDate
FROM Orders
WHERE EmployeeID = ?
ORDER BY CustomerId ASC;">
##########################################################
##########################################################
<SelectParameters>
<asp:SessionParameter //
Name="empid" //________________________
SessionField="empid" \\
DefaultValue="5" /> \\
</SelectParameters>
##########################################################
##########################################################
</asp:SqlDataSource>
<p>
<asp:GridView
id="GridView1"
runat="server"
DataSourceID="OdbcDataSource1" />
</p>
</form>
</body>
</html>
ASKER
I saw that...I need to programmatically change the value of that parameter based upon a value that the user selects during runtime from a dropdownlist...doe sthis work?
dsItemsDetail.InsertParame ters("RptT ype").Defa ultValue = 6
dsItemsDetail.InsertParame
Why not use a control parameter then?
<asp:controlparameter name="RptType" controlid="DropDownList1" propertyname="SelectedValu e"/>
<asp:controlparameter name="RptType" controlid="DropDownList1" propertyname="SelectedValu
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Why not use a control parameter then?
<asp:controlparameter name="RptType" controlid="DropDownList1" propertyname="SelectedValu
=====
okay so what do you do here...
if ddl.text = 'ALL" then
sql parameter = '4' 'RptType=4
end if
if ddl.text <> "ALL" then
Sql paramter = '6' 'RptTyp=6
end if