FormView无法显示

时间:2012-04-12 14:10:40

标签: asp.net formview

我一直在努力解决这个问题 - 我的FormView有一些文本字段,GridView有几列。出于某种原因,我的FormView不会显示GridView

我的.aspx文件如下:

FormView

<asp:FormView ID="frmPurchases" runat="server" DataKeyNames="ID"  DataSourceID="dsPurchases" DataMember="DefaultView" Width="100%" SkinID="formSkinPP" >
    <ItemTemplate>
        <asp:Label id="lblApproval" runat="server" Text="NOT APPROVED: the guids do not match...."></asp:Label>
        <br /><br />
        <div style="width:800px;padding:0px 0px 10px 0px;">
            <div style="float:left;width:400px;">
                <div style="float:left;width:100px;">Reference</div>                                  
                <div style="float:left;">
                    <asp:TextBox ID="txtReference" CssClass="TextBox" runat="server" Width="237px" ValidationGroup="Group1" Text='<%# Bind("SupplierReference") %>'></asp:TextBox><br />
                </div>
            </div>


        <div style="width:800px;padding:0px 0px 10px 0px;">
            <div style="float:left;width:400px;">
                <div style="float:left;width:100px;">Date</div>                                  
                <div style="float:left;">
                    <telerik:RadDatePicker DatePopupButton-CssClass="datePopUp" Width="260px" id="radDate" SelectedDate='<%# Bind("Date") %>' DateInput-BorderWidth="1px" DateInput-BorderColor="#7F9DB9" Runat="server" MinDate="2000-01-01">                                                    
                        <DateInput runat="server" DateFormat="dd/MM/yyyy" Width="260px" BorderColor="#7F9DB9" BorderWidth="1px" InvalidStyleDuration="100">
                        </DateInput>
                    </telerik:RadDatePicker>
                </div>
            </div>
        </div>

        <div style="width:800px;padding:0px 0px 10px 0px;">
            <div style="float:left;width:400px;">
                <div style="float:left;width:100px;">Type</div>                                  
                <div style="float:left;">
                    <asp:TextBox ID="txtType" runat="server" Width="240px" Text='<%# Bind("Type") %>'                            
                     ValidationGroup="Group1"></asp:TextBox><br />
                </div>
            </div>
        </div>

         <div style="width:800px;padding:0px 0px 10px 0px;">
            <div style="float:left;width:400px;">
                <div style="float:left;width:100px;">PO Number</div>                                  
                <div style="float:left;">
                    <asp:TextBox ID="acPONumber" runat="server" Width="240px" Text='<%# Bind("PONumber") %>'></asp:TextBox><br />

                </div>
            </div>
        </div>

         <div style="width:800px;padding:0px 0px 10px 0px;">
            <div style="float:left;width:400px;">
                <div style="float:left;width:100px;"><asp:Label ID="lblEstimatedAmount" runat="server" Text="Estimated Amount"></asp:Label></div>                                  
                <div style="float:left;">
                  <asp:TextBox ID="acEstimatedAmount" runat="server" Width="240px" Text='<%# Bind("Rate") %>'></asp:TextBox><br />                               
                </div>
            </div>
        </div>
        </div>
    </ItemTemplate>
</asp:FormView>

GridView

<asp:GridView ID="gridSupplierPurchasesDetail" DataSourceID="dsPurchasesDetail" runat="server" AutoGenerateColumns="False" AllowSorting="True" BorderStyle="Solid" BorderColor="#5E5EAE" BorderWidth="1pt"
CellPadding="5" Font-Names="Helvetica,Arial,Sans-Serif" Font-Size="9pt" DataMember="DefaultView"
SkinID="gridSkin" EmptyDataText="No Supplier Purchases Added to this Reference" 
EnableTheming="False" Width="755px" ShowFooter="True" FooterStyle-VerticalAlign="Top" RowStyle-VerticalAlign="Top">
    <HeaderStyle BackColor="#5E5EAE" ForeColor="White" HorizontalAlign="Left" />                     
    <EmptyDataRowStyle VerticalAlign="Top" />
    <RowStyle VerticalAlign="Top" />
    <FooterStyle VerticalAlign="Top" />
    <Columns>
        <asp:TemplateField HeaderText="Description" SortExpression="Description">                                       
            <ItemTemplate> 
                <asp:TextBox ID="txtDescription" Width="200px" runat="server" Text='<%# Bind("Description") %>'></asp:TextBox> 

            </ItemTemplate> 
        </asp:TemplateField> 
        <asp:TemplateField HeaderText="NetAmount" SortExpression="NetAmount">                                     
            <ItemTemplate> 
                <asp:TextBox ID="txtNetAmount" width="80px" runat="server" Text='<%# Bind("NetAmount") %>'></asp:TextBox> 

            </ItemTemplate> 
        </asp:TemplateField>
        <asp:TemplateField HeaderText="VATRates" SortExpression="VATRates">                                       
            <ItemTemplate> 
                <asp:DropDownList AutoPostBack="true"  
                    ID="ddlVATRates" runat="server"  
                         Width="80px"></asp:DropDownList>

            </ItemTemplate>                                         
        </asp:TemplateField>
        <asp:TemplateField HeaderText="VATAmount" SortExpression="VATAmount">                                         
            <ItemTemplate> 
                <asp:TextBox ID="txtVATAmount" width="80px" runat="server"  Text='<%# Bind("VATAmount") %>' ReadOnly="true"></asp:TextBox> 
            </ItemTemplate> 
        </asp:TemplateField>
        <asp:TemplateField HeaderText="TotalAmount" SortExpression="TotalAmount"> 

            <ItemTemplate> 
                <asp:TextBox ID="txtTotalAmount" width="80px" runat="server" Text='<%# Bind("TotalAmount") %>' ReadOnly="true"></asp:TextBox> 
            </ItemTemplate> 
        </asp:TemplateField>

        <asp:TemplateField HeaderText="PartNumber" SortExpression="PartNumber">                
            <ItemTemplate> 
                <asp:TextBox ID="txtPartNumber" runat="server" class="PartNumber" Width="100px" Text='<%# Bind("PartNumber") %>' ValidationGroup="Group2"></asp:TextBox>
            </ItemTemplate> 
        </asp:TemplateField>                                    
    </Columns>
</asp:GridView>

数据源控件:

<asp:ObjectDataSource ID="dsPurchases" runat="server" SelectMethod="GetSupplierPurchasesByID" TypeName="SupplierPurchasesSystem" OldValuesParameterFormatString="original_{0}" >
    <SelectParameters>
        <asp:Parameter Name="SupplierPurchasesID" Type="Int32" DefaultValue="13243" />
        <asp:Parameter DefaultValue="VNE_DB" Name="DataSource" Type="String" />
    </SelectParameters>
</asp:ObjectDataSource>
    <asp:ObjectDataSource ID="dsPurchasesDetail" runat="server" SelectMethod="GetSupplierPurchasesDetails"
        TypeName="SupplierPurchasesSystem" >
        <SelectParameters>
            <asp:ControlParameter ControlID="HiddenField1" DefaultValue="" Name="guid" PropertyName="Value"
                Type="String" />
            <asp:Parameter DefaultValue="VNE_DB" Name="DataSource" Type="String" />
        </SelectParameters>
    </asp:ObjectDataSource>
<asp:HiddenField ID="HiddenField1" runat="server" />

非常感谢任何帮助。

1 个答案:

答案 0 :(得分:11)

老实说,FormView未显示的最可能原因是您没有从数据源中获取任何内容。您可以为FormView创建EmptyDataTemplate以确定。在</ItemTemplate>之前和</asp:FormView>

之前,将其放在正确的位置
<EmptyDataTemplate>
    There is nothing to see here.
</EmptyDataTemplate>