Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.6k views
in Technique[技术] by (71.8m points)

vb.net - Visual Basic needs single SQL data call for multiple dropdowns with same data

I'm trying to create a Visual Basic page that has multiple dropdown with the some set of data, but the data is called from a SQL server for its initial creation. I'm using the same SqlDataSource for all five dropdowns, but I fear it is calling it five times per row per the number of rows I have. At least, I think it is going slower than it should be.

Here is what I have for each dropdown's code

<div dlass="DataDropDownColumn">
    <div>DataDropDownColumnEntry1</div>
    <div class="DropDownSelectionBox">
        <asp:DropDownList ID="ddlEntry1" runat="server" SelectedValue='<%# DataBinder.Eval(Container, "DataItem.Entry1") %>'
            DataSourceID="SqlDataSource1" DataTextField="EntryID" DataValueField="ID" AppendDataBoundItems="true">
            <asp:ListItem Selected="True" Text="Select" Value="" />
            <aps:ListItem Text=" " Value="0" />
        </asp:DropDownList>
    </div>
</div>
<div dlass="DataDropDownColumn">
    <div>DataDropDownColumnEntry2</div>
    <div class="DropDownSelectionBox">
        <asp:DropDownList ID="ddlEntry2" runat="server" SelectedValue='<%# DataBinder.Eval(Container, "DataItem.Entry2") %>'
            DataSourceID="SqlDataSource1" DataTextField="EntryID" DataValueField="ID" AppendDataBoundItems="true">
            <asp:ListItem Selected="True" Text="Select" Value="" />
            <aps:ListItem Text=" " Value="0" />
        </asp:DropDownList>
    </div>
</div>
<div dlass="DataDropDownColumn">
    <div>DataDropDownColumnEntry3</div>
    <div class="DropDownSelectionBox">
        <asp:DropDownList ID="ddlEntry3" runat="server" SelectedValue='<%# DataBinder.Eval(Container, "DataItem.Entry3") %>'
            DataSourceID="SqlDataSource1" DataTextField="EntryID" DataValueField="ID" AppendDataBoundItems="true">
            <asp:ListItem Selected="True" Text="Select" Value="" />
            <aps:ListItem Text=" " Value="0" />
        </asp:DropDownList>
    </div>
</div>

This is repeated several times with different IDs for the ddlEntry and different matching DataBinder Evals for the ddlEntry. Again the DataSourceID for each one is the same:

<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
    SelectCommand="SELECT ID FROM tblEntries ORDER BY ID"
</asp:SqlDataSource>

My belief is that there are multiple calls for each ddlEntry, even though the data is the same. Am I mistaken, and ASP is smart enough to just get the data one time, and apply it to all the HTML Dropdown List entries? It would be nice, but it seems a little slow bringing up the page.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...