• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 725
  • Last Modified:

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: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>


I have also tried, but not working:
   <asp:Parameter Name="RptType" Type="Int32" DefaultValue=Session('rptShoereporting') />
0
GlobaLevel
Asked:
GlobaLevel
1 Solution
 
käµfm³d 👽Commented:
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
0
 
GlobaLevelAuthor Commented:
kaufmed...

can you give me some kind of example....that link doesnt really provide one...

does it need to use:
          dsItemsDetail.InsertParameters("RptType").DefaultValue = 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!

0
 
käµfm³d 👽Commented:
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>

Open in new window

0
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 
GlobaLevelAuthor Commented:
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.InsertParameters("RptType").DefaultValue = 6
0
 
CodeCruiserCommented:
Why not use a control parameter then?

<asp:controlparameter name="RptType" controlid="DropDownList1" propertyname="SelectedValue"/>
0
 
GlobaLevelAuthor Commented:

Why not use a control parameter then?

<asp:controlparameter name="RptType" controlid="DropDownList1" propertyname="SelectedValue"/>

=====

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
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

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