Link to home
Start Free TrialLog in
Avatar of GlobaLevel
GlobaLevelFlag for United States of America

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: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') />
Avatar of kaufmed
kaufmed
Flag of United States of America image

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
Avatar of GlobaLevel

ASKER

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!

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

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
Why not use a control parameter then?

<asp:controlparameter name="RptType" controlid="DropDownList1" propertyname="SelectedValue"/>
ASKER CERTIFIED SOLUTION
Avatar of ExpertLogin_890
ExpertLogin_890
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

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