ListView没有返回任何数据

时间:2015-10-21 19:38:53

标签: c# asp.net

我是ASP.net的初学者所以请耐心等待。我正在尝试一个基本的编辑功能,让学生编辑他们的细节。这涉及将一个表连接到另一个表。编辑在内部联接之前工作正常,但是一旦我将其添加到select命令,现在我在呈现网站时没有收到任何数据。任何帮助将不胜感激。

<form id="form1" runat="server">
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString='<%$ ConnectionStrings:ConnectionString %>' 
            SelectCommand="SELECT student.Id, student.studentno, student.pword, student.fname, student.lname, student.pathway, pathway.pathwayname FROM student INNER JOIN pathway ON student.pathway = pathway.pathwayname WHERE (student.studentno = @studentno)"
            UpdateCommand="UPDATE student SET student.fname=@fname, student.lname=@lname WHERE student.Id=@ID">
            <UpdateParameters>
                <asp:Parameter Name="studentno" Type="Int32" />
                <asp:Parameter Name="lname" Type="String" />
                <asp:Parameter Name="pathway" Type="int32" />
                <asp:Parameter Name="fname" Type="String" />
                <asp:Parameter Name="pword" Type="String" />
                <asp:Parameter Name="id" Type="Int32" />
            </UpdateParameters>
            <SelectParameters>
                <asp:QueryStringParameter Name="studentno" QueryStringField="studentno" Type="Int32" />
            </SelectParameters>
        </asp:SqlDataSource>
    <div>
        <asp:Label ID="username" runat="server" Text=""></asp:Label>

        <asp:ListView ID="displayedit" runat="server" DataSourceID="SqlDataSource1" DataKeyNames="Id">
            <EditItemTemplate>
                <span style="">
                studentno:
                <asp:Label ID="studentnoLabel" runat="server" Text='<%# Eval("studentno") %>' />
                <br />
                fname:
                <asp:TextBox ID="fnameTextBox" runat="server" Text='<%# Bind("fname") %>' />
                <br />
                lname:
                <asp:TextBox ID="lnameTextBox" runat="server" Text='<%# Bind("lname") %>' />
                <br />
                pathway:
                <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("pathway") %>' />
                <br />                <asp:Button ID="UpdateButton" runat="server" CommandName="Update" Text="Update" />
                <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Cancel" />
                <br /><br /></span>
            </EditItemTemplate>
            <EmptyDataTemplate>
                <span>No data was returned.</span>
            </EmptyDataTemplate>
            <InsertItemTemplate>
                <span style="">studentno:
                <asp:TextBox ID="studentnoTextBox" runat="server" Text='<%# Bind("studentno") %>' />
                <br />pword:
                <asp:TextBox ID="pwordTextBox" runat="server" Text='<%# Bind("pword") %>' />
                <br />fname:
                <asp:TextBox ID="fnameTextBox" runat="server" Text='<%# Bind("fname") %>' />
                <br />lname:
                <asp:TextBox ID="lnameTextBox" runat="server" Text='<%# Bind("lname") %>' />
                <br />
                <asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="Insert" />
                <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Clear" />
                <br /><br /></span>
            </InsertItemTemplate>
            <ItemTemplate>
                <span style="">
                studentno:
                <asp:Label ID="studentnoLabel" runat="server" Text='<%# Eval("studentno") %>' />
                <br />
                pword:
                <asp:Label ID="pwordLabel" runat="server" Text='<%# Eval("pword") %>' />
                <br />
                fname:
                <asp:Label ID="fnameLabel" runat="server" Text='<%# Eval("fname") %>' />
                <br />
                lname:
                <asp:Label ID="lnameLabel" runat="server" Text='<%# Eval("lname") %>' />
                <br />
                pathway:
                <asp:Label ID="Label1" runat="server" Text='<%# Eval("pathway") %>' />
                <br />
                <asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
<br />
                <br />
                </span>
            </ItemTemplate>
            <LayoutTemplate>
                <div id="itemPlaceholderContainer" runat="server" style="">
                    <span runat="server" id="itemPlaceholder" />
                </div>
                <div style="">
                    <asp:DataPager ID="DataPager1" runat="server">
                        <Fields>
                            <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" ShowLastPageButton="True" />
                        </Fields>
                    </asp:DataPager>
                </div>
            </LayoutTemplate>
            <SelectedItemTemplate>
                <span style="">Id:
                <asp:Label ID="IdLabel" runat="server" Text='<%# Eval("Id") %>' />
                <br />
                studentno:
                <asp:Label ID="studentnoLabel" runat="server" Text='<%# Eval("studentno") %>' />
                <br />
                pword:
                <asp:Label ID="pwordLabel" runat="server" Text='<%# Eval("pword") %>' />
                <br />
                fname:
                <asp:Label ID="fnameLabel" runat="server" Text='<%# Eval("fname") %>' />
                <br />
                lname:
                <asp:Label ID="lnameLabel" runat="server" Text='<%# Eval("lname") %>' />
                <br />
                <asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
<br />
                <br />
                </span>
            </SelectedItemTemplate>
        </asp:ListView>



    </div>
    </form>

0 个答案:

没有答案