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

x
?
Solved

Why does't the asp.net code work

Posted on 2014-07-11
3
Medium Priority
?
43 Views
Last Modified: 2015-06-01
This is an ASP.Net 4.5 question with Visual Studio 2013: I have determined that the following code works if I create an empty website project in Visual Studio 2013. If I do not create an empty website then when I post a formfield from one page to another page the datalist does not display at all which I would assume because the formfield values have not been passed. Would anyone know why creating a full project in ASP.Net 4.5 would cause this to happen and how can I correct it.

Page that performs the post
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="send.aspx.vb" Inherits="send" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
        <asp:TextBox ID="bodypartmg" runat="server"></asp:TextBox>
        <asp:Button ID="Button1" runat="server" PostBackUrl="~/recev.aspx" Text="Button" />
    
    </div>
    </form>
</body>
</html>

Open in new window


Page that receives the post
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="recev.aspx.vb" Inherits="recev" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:SQL2008R2_504887_golivefitnesConnectionString %>" SelectCommand="sp_gettheresults" SelectCommandType="StoredProcedure">
            <SelectParameters>
                <asp:FormParameter FormField="bodypartmg" Name="bodypartmg" Type="String" />
            </SelectParameters>
        </asp:SqlDataSource>
        <br />
        <asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1">
            <ItemTemplate>
                name:
                <asp:Label ID="nameLabel" runat="server" Text='<%# Eval("name") %>' />
        <br />
                bodypartmg:
                <asp:Label ID="bodypartmgLabel" runat="server" Text='<%# Eval("bodypartmg") %>' />
        <br />
                bodypartspecific:
                <asp:Label ID="bodypartspecificLabel" runat="server" Text='<%# Eval("bodypartspecific") %>' />
        <br />
                secondary_areas:
                <asp:Label ID="secondary_areasLabel" runat="server" Text='<%# Eval("secondary_areas") %>' />
        <br />
<br />
            </ItemTemplate>
        </asp:DataList>
    
    </div>
    </form>
</body>
</html>

Open in new window



WebConfig
<?xml version="1.0"?>

<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->

<configuration>
  <connectionStrings>
    
    <add name="FitnessConnectionString" connectionString="Data Source=DM-MOBILE-2014\MSSQLSVR2008;Initial Catalog=BaseCustomers;Persist Security Info=True;User ID=User1;Password=xuser12five" providerName="System.Data.SqlClient"/>
   
  </connectionStrings>  
  
  
  <system.web>
      <compilation debug="true" strict="false" explicit="true" targetFramework="4.5.1" />
      <httpRuntime targetFramework="4.5.1" />
    </system.web>

</configuration>

Open in new window

0
Comment
Question by:derrekdeveloper
2 Comments
 
LVL 2

Accepted Solution

by:
saritapatel earned 2000 total points
ID: 40335994
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:SQL2008R2_504887_golivefitnesConnectionString %>" SelectCommand="sp_gettheresults" SelectCommandType="StoredProcedure">
            <SelectParameters>
                <asp:FormParameter FormField="bodypartmg" Name="bodypartmg" Type="String" />
            </SelectParameters>
        </asp:SqlDataSource>

Open in new window


Change it to
    
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$  FitnessConnectionString %>" SelectCommand="sp_gettheresults" SelectCommandType="StoredProcedure">
            <SelectParameters>
                <asp:FormParameter FormField="bodypartmg" Name="bodypartmg" Type="String" />
            </SelectParameters>
        </asp:SqlDataSource>

Open in new window

0
 

Author Closing Comment

by:derrekdeveloper
ID: 40806234
Thanks for the help.
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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
Suggested Courses

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question