多选列表框中的gridview文件

多选列表框中的gridview文件

本文介绍了多选列表框中的gridview文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HiI有一个列表框,该列表框绑定到数据库中的表.它产生公司列表.然后,用户将出现并选择他们想要查看其信息的多个公司,然后他们单击一个selet按钮,该按钮将无法在下面的网格视图中显示公司信息(例如公司名称,公司站点,地址等).但是我遇到的问题是,它只显示所选的多个公司之一,并且始终显示排名第一.

有人可以说明我如何使所有公司显示在Gridview中吗?

我正在vb.net中编程

请参见下面的源代码

HiI have a list box that is bound to a table in a database. it produces a list of companies. The user will then come along and select multiple companies that they want to view information about, and then they hit a selet button which ill display the company information (e.g company name, company site, address e.t.c) in a gridview underneath. however the issue that i am having is that it only displays ONE of the multiple companies selected and its always the top one.

Can someone please shed some light on how i get all the companies to be displayed in the gridview?

i am programming in vb.net

please see source code below

<asp:ListBox ID="ListBox1" runat="server"

            DataSourceID="SqlDataSource11" DataTextField="compName"

            DataValueField="compDataID" SelectionMode="Multiple" AutoPostBack="True"></asp:ListBox>
        <asp:SqlDataSource ID="SqlDataSource11" runat="server"

            ConnectionString="<%$ ConnectionStrings:IWSRiskAssessmentConnectionString %>"

            SelectCommand="SELECT [compDataID], [compName] FROM [tblCompany] WHERE ([compDataID] &lt;&gt; @compDataID) ORDER BY [compName]">
            <SelectParameters>
                <asp:ControlParameter ControlID="DropDownList1" Name="compDataID"

                    PropertyName="SelectedValue" Type="Int32" />
            </SelectParameters>
        </asp:SqlDataSource>





<asp:GridView

            ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False"

            DataSourceID="SqlDataSource2">
            <Columns>
                <asp:BoundField DataField="compName" HeaderText="compName"

                    SortExpression="compName" />
                <asp:BoundField DataField="Site Name" HeaderText="Site Name"

                    SortExpression="Site Name" />
                <asp:BoundField DataField="Reference Number" HeaderText="Reference Number"

                    SortExpression="Reference Number" />
                <asp:BoundField DataField="Asset" HeaderText="Asset" ReadOnly="True"

                    SortExpression="Asset" />
                <asp:BoundField DataField="Location" HeaderText="Location"

                    SortExpression="Location" />
                <asp:BoundField DataField="Block" HeaderText="Block" SortExpression="Block" />
                <asp:BoundField DataField="Room" HeaderText="Room" SortExpression="Room" />
            </Columns>
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource2" runat="server"

            ConnectionString="<%$ ConnectionStrings:IWSRiskAssessmentConnectionString %>"

            SelectCommand="SELECT tblCompany.compName, tblSite.siteName AS [Site Name], tblSite.siteUPRN AS [Reference Number], tblIncMain.incAsset + ' ' + CAST(tblIncMain.incNumber AS varchar) AS Asset, tblIncMain.incLocation AS Location, tblIncMain.incBlock AS Block, tblIncMain.incRoom AS Room FROM tblIncMain INNER JOIN tblSite ON tblIncMain.incSite = tblSite.siteID INNER JOIN tblCompany ON tblSite.siteCompany = tblCompany.compDataID WHERE (tblIncMain.incActive = 1) AND (tblSite.siteActive = 1) AND (tblIncMain.incRemoved = 0) AND (tblCompany.compDataID = @compDataID) ORDER BY [Site Name], tblIncMain.incAsset, tblIncMain.incNumber">
            <SelectParameters>
                <asp:ControlParameter ControlID="ListBox1" Name="compDataID"

                    PropertyName="SelectedValueList" />
            </SelectParameters>
        </asp:SqlDataSource>




非常感谢任何帮助.




any help is much appreciated

推荐答案





<asp:GridView

            ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False"

            DataSourceID="SqlDataSource2">
            <Columns>
                <asp:BoundField DataField="compName" HeaderText="compName"

                    SortExpression="compName" />
                <asp:BoundField DataField="Site Name" HeaderText="Site Name"

                    SortExpression="Site Name" />
                <asp:BoundField DataField="Reference Number" HeaderText="Reference Number"

                    SortExpression="Reference Number" />
                <asp:BoundField DataField="Asset" HeaderText="Asset" ReadOnly="True"

                    SortExpression="Asset" />
                <asp:BoundField DataField="Location" HeaderText="Location"

                    SortExpression="Location" />
                <asp:BoundField DataField="Block" HeaderText="Block" SortExpression="Block" />
                <asp:BoundField DataField="Room" HeaderText="Room" SortExpression="Room" />
            </Columns>
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource2" runat="server"

            ConnectionString="<%





any help is much appreciated




any help is much appreciated



这篇关于多选列表框中的gridview文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 08:07