0

我正在尝试在我的 asp.net 应用程序上修复黄色死亡页面当我加载它给我的页面时,asp.net 绑定到这个 ddl_username “Guid 应该包含 32 位数字和 4 个破折号(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)。” 我知道这是因为 -1 值可以帮助解决这个问题

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <style type="text/css">
        .style1
        {
            height: 24px;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <table class="ui-accordion">
        <tr>
            <td>
                <label>Tech User name:</label></td>
            <td>
                <asp:DropDownList ID="ddl_userNames" runat="server" 
                    DataSourceID="SqlDS_techNames" DataTextField="UserName" 
                    DataValueField="UserId" AppendDataBoundItems="True" AutoPostBack="True">
                    <asp:ListItem Value="-1">Select one</asp:ListItem>
                </asp:DropDownList>
                <asp:SqlDataSource ID="SqlDS_techNames" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:Compudata_ProjectManagerConnection %>" 
                    SelectCommand="SELECT [UserId], [UserName] FROM [vw_aspnet_Users]">
                </asp:SqlDataSource>
            </td>
        </tr>
        <tr>
            <td>
               <label>Sesrch terms:</label> </td>
            <td>
                               <asp:DropDownList ID="ddl_SesrchTerms" runat="server" 
                >
                                   <asp:ListItem Value="-1">Select One</asp:ListItem>
                                   <asp:ListItem Value="1">Daily</asp:ListItem>
                                   <asp:ListItem Value="2">Weekly</asp:ListItem>
                                   <asp:ListItem Value="3">Monthly</asp:ListItem>
                               </asp:DropDownList></td>
        </tr>
        <tr>
            <td>
                <label>Date:</label></td>
            <td>
                <asp:TextBox ID="txtb_date" runat="server"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style1">
                <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
            </td>
            <td class="style1">
                <asp:Label ID="lbl_msg" runat="server"></asp:Label>
            </td>
        </tr>
    </table>
    <br />
    <br />
    <br />


    <asp:Chart ID="Chart1" runat="server" 
        DataSourceID="SqlDS_Get_Individual_Tech_Service_Chart">
        <Series>
            <asp:Series Name="Series1" ChartType="Pie" XValueMember="billableTypeName" 
                YValueMembers="TotalTime">
            </asp:Series>
        </Series>
        <ChartAreas>
            <asp:ChartArea Name="ChartArea1">
            </asp:ChartArea>
        </ChartAreas>
    </asp:Chart>
    <asp:SqlDataSource ID="SqlDS_Get_Individual_Tech_Service_Chart" runat="server" 
        ConnectionString="<%$ ConnectionStrings:Compudata_ProjectManagerConnection %>" 
        SelectCommand="Get_Individual_Tech_Service_Chart" 
        SelectCommandType="StoredProcedure">
        <SelectParameters>
            <asp:ControlParameter ControlID="ddl_SesrchTerms" DbType="Int32" 
                Name="SearchTerms" PropertyName="SelectedValue" />
            <asp:ControlParameter ControlID="ddl_techNames" DbType="Guid" Name="TechID" 
                PropertyName="SelectedValue" />
            <asp:ControlParameter ControlID="txtb_date" DbType="DateTime" Name="Date" 
                PropertyName="Text" />
        </SelectParameters>
    </asp:SqlDataSource>
</asp:Content>
4

1 回答 1

1

您始终可以在 page_load 中添加额外的行以插入带有空 guid 的“Select One”

ddl_userNames.Items.Insert(0, new ListItem("Select one", Guid.Empty.ToString()));
于 2013-02-14T20:10:37.823 回答