2 Replies - 1379 Views - Last Post: 09 July 2010 - 09:00 PM Rate Topic: -----

#1 bravo659  Icon User is offline

  • D.I.C Head

Reputation: -3
  • View blog
  • Posts: 181
  • Joined: 18-May 08

Web Programming ASP.Net with VB

Posted 06 July 2010 - 09:18 PM

Hello, I am having some trouble and been working at this for a few days already and seem can't find the solution. Wondering if you can help.
Below see the Server Error with the Stack Trace. I can't figure it out.
Also, please see the code for the project.
Can anyone please help thanks.

<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="CustomerMaintenance.aspx.vb" Inherits="CustomerMaintenance" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    </asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<table>
    <tr>
    <td>
       <%--gridview display data retrieved from database--%>
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
        DataMember="DefaultView" 
        DataSourceID="SqlDataSource1" AllowPaging="True" AllowSorting="True" 
            DataKeyNames="CustomerID">
        <RowStyle BackColor="White" ForeColor="Black" />
        
       <%-- adding columns that is bound to the database--%>
        <Columns>
            <asp:BoundField DataField="Name" HeaderText="Name" ReadOnly="True" 
                SortExpression="Name" />
            <asp:BoundField DataField="City" HeaderText="City" SortExpression="City" />
            <asp:BoundField DataField="State" HeaderText="State" 
                SortExpression="State" />
                <asp:CommandField ButtonType="Button" SelectText="Select" ShowSelectButton="True" />
        </Columns>
        
       <%-- adding style to the pages--%>
        <PagerStyle BackColor="Silver" ForeColor="Blue" HorizontalAlign="Center" />
        <SelectedRowStyle BackColor="Blue" ForeColor="White" />
        <HeaderStyle BackColor="Silver" Font-Bold="True" ForeColor="White" />
        <AlternatingRowStyle BackColor="WhiteSmoke" ForeColor="Black" />
        <%--end of gridview design--%>
    </asp:GridView>
        <%-- adding columns that is bound to the database--%>    <%-- adding style to the pages--%>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:TechSupportConnectionString %>" 
        SelectCommand="SELECT [Name], [City], [State] FROM [Customers]">
        <%--close connection--%>
    </asp:SqlDataSource>
    </td>
    <td class="style2" valign="top">
    <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" 
        DataKeyNames="CustomerID" DataSourceID="SqlDataSource2" Height="50px" 
        Width="400px">
        <RowStyle BackColor="#DEDFDE" ForeColor="Black" />
        
        <Fields>
            <asp:BoundField DataField="CustomerID" HeaderText="CustomerID" ReadOnly="True" 
                SortExpression="CustomerID" />
            <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
            <asp:BoundField DataField="Address" HeaderText="Address" 
                SortExpression="Address" />
            <asp:BoundField DataField="City" HeaderText="City" 
                SortExpression="City" />
            <asp:BoundField DataField="State" HeaderText="State" 
                SortExpression="State" />
            <asp:BoundField DataField="ZipCode" HeaderText="ZipCode" 
                SortExpression="ZipCode" />
            <asp:BoundField DataField="Phone" HeaderText="Phone" 
                SortExpression="Phone" />
            <asp:BoundField DataField="Email" HeaderText="Email" 
                SortExpression="Email" />
                <asp:CommandField ButtonType="Button" 
                ShowDeleteButton="true"
                ShowEditButton="true"
                ShowInsertButton="true" />
        </Fields>
    </asp:DetailsView>
    
    
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
    ConflictDetection="CompareAllValues"
        ConnectionString="<%$ ConnectionStrings:TechSupportConnectionString2 %>" 
        OldValuesParameterFormatString="original_{0}"
        SelectCommand="SELECT * FROM [Customers]
        WHERE ([CustomerID] = @CustomerID)"
        DeleteCommand="DELETE FROM [Customers]
        WHERE [CustomerID] = @original_CustomerID
        AND   [Name] = @original_Name
        AND   [Address] = @original_Address
        AND   [City] = @original_City
        AND   [State] = @original_State
        AND   [ZipCode] = @original_ZipCode
        AND   [Phone] = @original_Phone
        AND   [Email] = @original_Email"
        InsertCommand="INSERT INTO [Customers]
        ([CustomerID], [Name], [Address], [City], [State], [ZipCode], [Phone], [Email])
        VALUES (@CustomerID, @Name, @Address, @City, @State, @ZipCode, @Phone, @Email)"
        UpdateCommand="UPDATE [Customers] SET [Name] = @Name,
        [Address] = @Address,
        [City] = @City,
        [State] = @State,
        [ZipCode] = @ZipCode, 
        [Phone] = @Phone,
        [Email] = @Email
        WHERE [CustomerID] = @original_CustomerID
        AND   [Name] = @original_Name
        AND   [Address] = @original_Address
        AND   [City] = @original_City
        AND   [State] = @original_State
        AND   [ZipCode] = @original_ZipCode
        AND   [Phone] = @original_Phone
        AND   [Email] = @original_Email">
       <%--Selecting parameterss to select--%>
       <SelectParameters>
       <asp:ControlParameter ControlID="GridView1" Name="CustomerID"
       PropertyName="SelectedValue" Type="String" />
       </SelectParameters>
       
       <%--Delete Parameters--%>
       <DeleteParameters>
       <asp:Parameter Name="original_CustomerID" Type="String" />
       <asp:Parameter Name="original_Name" Type="String" />
       <asp:Parameter Name="original_Address" Type="String" />
       <asp:Parameter Name="original_City" Type="String" />
       <asp:Parameter Name="original_State" Type="String" />
       <asp:Parameter Name="original_ZipCode" Type="String" />
       <asp:Parameter Name="original_Phone" Type="String" />
       <asp:Parameter Name="original_Email" Type="String" />

       </DeleteParameters>
       <UpdateParameters>
       <asp:Parameter Name="original_CustomerID" Type="String" />
       <asp:Parameter Name="original_Name" Type="String" />
       <asp:Parameter Name="original_Address" Type="String" />
       <asp:Parameter Name="original_City" Type="String" />
       <asp:Parameter Name="original_State" Type="String" />
       <asp:Parameter Name="original_ZipCode" Type="String" />
       <asp:Parameter Name="original_Phone" Type="String" />
       <asp:Parameter Name="original_Email" Type="String" />
       </UpdateParameters>
       <InsertParameters>
       <asp:Parameter Name="original_CustomerID" Type="String" />
       <asp:Parameter Name="original_Name" Type="String" />
       <asp:Parameter Name="original_Address" Type="String" />
       <asp:Parameter Name="original_City" Type="String" />
       <asp:Parameter Name="original_State" Type="String" />
       <asp:Parameter Name="original_ZipCode" Type="String" />
       <asp:Parameter Name="original_Phone" Type="String" />
       <asp:Parameter Name="original_Email" Type="String" />
       </InsertParameters>
       <%--end of parameters--%>
        </asp:SqlDataSource>
        
        <br />      
       
        </td>
        </tr>
        </table>




Server Error in '/Unit 8' Application.
--------------------------------------------------------------------------------

DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'CustomerID'.
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.Data.DataRowView' does not contain a property with the name 'CustomerID'.

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:


[HttpException (0x80004005): DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'CustomerID'.]
System.Web.UI.DataBinder.GetPropertyValue(Object container, String propName) +8660309
System.Web.UI.WebControls.GridView.CreateChildControls(IEnumerable dataSource, Boolean dataBinding) +2178
System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) +57
System.Web.UI.WebControls.GridView.PerformDataBinding(IEnumerable data) +14
System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +114
System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +31
System.Web.UI.WebControls.DataBoundControl.PerformSelect() +142
System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +73
System.Web.UI.WebControls.GridView.DataBind() +4
System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +82
System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() +72
System.Web.UI.Control.EnsureChildControls() +87
System.Web.UI.Control.PreRenderRecursiveInternal() +44
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842

Is This A Good Question/Topic? 0
  • +

Replies To: Web Programming ASP.Net with VB

#2 demausdauth  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 162
  • View blog
  • Posts: 565
  • Joined: 03-February 10

Re: Web Programming ASP.Net with VB

Posted 09 July 2010 - 11:32 AM

Not sure if this solves the issue or not but it does seem like it would be an issue.

These parameters
 <InsertParameters>
       <asp:Parameter Name="original_CustomerID" Type="String" />
       <asp:Parameter Name="original_Name" Type="String" />
       <asp:Parameter Name="original_Address" Type="String" />
       <asp:Parameter Name="original_City" Type="String" />
       <asp:Parameter Name="original_State" Type="String" />
       <asp:Parameter Name="original_ZipCode" Type="String" />
       <asp:Parameter Name="original_Phone" Type="String" />
       <asp:Parameter Name="original_Email" Type="String" />
</InsertParameters>



don't seem to match these

InsertCommand="INSERT INTO [Customers]
        ([CustomerID], [Name], [Address], [City], [State], [ZipCode], [Phone], [Email])
        VALUES (@CustomerID, @Name, @Address, @City, @State, @ZipCode, @Phone, @Email)"



Shouldn't the Values() match?
Was This Post Helpful? 0
  • +
  • -

#3 bravo659  Icon User is offline

  • D.I.C Head

Reputation: -3
  • View blog
  • Posts: 181
  • Joined: 18-May 08

Re: Web Programming ASP.Net with VB

Posted 09 July 2010 - 09:00 PM

View Postdemausdauth, on 09 July 2010 - 10:32 AM, said:

Not sure if this solves the issue or not but it does seem like it would be an issue.

These parameters
 <InsertParameters>
       <asp:Parameter Name="original_CustomerID" Type="String" />
       <asp:Parameter Name="original_Name" Type="String" />
       <asp:Parameter Name="original_Address" Type="String" />
       <asp:Parameter Name="original_City" Type="String" />
       <asp:Parameter Name="original_State" Type="String" />
       <asp:Parameter Name="original_ZipCode" Type="String" />
       <asp:Parameter Name="original_Phone" Type="String" />
       <asp:Parameter Name="original_Email" Type="String" />
</InsertParameters>



don't seem to match these

InsertCommand="INSERT INTO [Customers]
        ([CustomerID], [Name], [Address], [City], [State], [ZipCode], [Phone], [Email])
        VALUES (@CustomerID, @Name, @Address, @City, @State, @ZipCode, @Phone, @Email)"



Shouldn't the Values() match?


Well, according to the code it does match, but according to the error it don't.
I also believe there is nothing wrong with the code or is there?
My Professor also seem not to understand why this is happening. I got it to work a bit for three screenshots then it rendered another error. Wanna see it? Since this posting I have been trying to work on it.
Please see the attached screenshot.

Attached File(s)


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1