我想開發一個ASP.NET頁面,它將顯示我的數據庫中的條目。我的查詢中有大約16列。但是,如果我把我的代碼中的所有16列的查詢,GridView不顯示。所有的數據不適合數據網格視圖
只有當我的查詢中的列數不超過8列時,纔會出現在頁面上。我不知道該怎麼辦纔能有人幫助我嗎?
這些查詢和防曬結束的代碼示例來填充查詢
<asp:GridView ID="GridView1" runat="server" CellPadding="4" ForeColor="#333333"
GridLines="None" Width="900px">
<AlternatingRowStyle BackColor="White" />
<EditRowStyle BackColor="#2461BF" />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#EFF3FB" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F5F7FB" />
<SortedAscendingHeaderStyle BackColor="#6D95E1" />
<SortedDescendingCellStyle BackColor="#E9EBEF" />
<SortedDescendingHeaderStyle BackColor="#4870BE" />
</asp:GridView>
這也是我如何填充它:
Try
myconn.Open()
Dim sqlstring As String = "SELECT a.account_id AS 'No', a.accountid_number AS 'ID', CONCAT(account_name,' ',account_midname,' ',account_surname) AS 'Student Name', a.account_type As 'Type', l.live_mail AS 'Acount Name' AS 'Password' FROM account a, liveaccount l WHERE a.account_id = l.l_account_id"
Dim smd As MySqlCommand
smd = New MySqlCommand(sqlstring, myconn)
smd.CommandType = CommandType.Text
Dim da As New MySqlDataAdapter(smd)
Dim cb As New MySqlCommandBuilder(da)
Dim ds As New DataSet()
da.Fill(ds)
GridView1.DataSource = ds.Tables(0)
GridView1.DataBind()
myconn.Close()
Catch ex As Exception
myconn.Close()
End Try
這是查詢該工作。如果我想補充甚至一列越不露面:
SELECT a.account_id AS 'No', a.accountid_number AS 'ID', CONCAT(account_name,' ',account_midname,' ',account_surname) AS 'Student Name', a.account_type As 'Type', l.live_mail AS 'Acount Name' FROM account a, liveaccount l WHERE a.account_id = l.l_account_id"
,這其中一個想工作,但如果我插入GridView控件顯示不出來:
SELECT a.account_id AS 'No', a.accountid_number AS 'ID', a.account_type AS 'Type', a.account_name || ' ' || a.account_midname || ' ' || a.account_surname AS 'Student Name', a.account_birthdate AS 'BirthDate', l.gender AS 'Gender', l.position AS 'Position', l.office_department AS 'Office/Department', l.date_created AS 'Date Created', time_created AS 'Time Created', l.office_tel AS 'Tel No', office_localno AS 'Office Tel', l.contact_no 'Cell Phone', l.alternate_email AS 'Other Email', l.classification AS 'Classification', l.registered AS 'Status' FROM account a, liveaccount l WHERE a.account_id = l.l_account_id AND l.registered = 'NOTREGISTERED' AND a.account_deleted = 0 ORDER BY a.account_id Desc;
gridview沒有列的限制,它可能是一個CSS問題,專注於此。 – 2013-02-25 00:05:50
驗證第二次選擇的「Student Name」列上的連接,它與第一個不同,也許你只需要使用CONCAT功能。 – 2013-02-25 00:24:13