简体   繁体   English

System.Byte []显示在Datagrid列中

[英]System.Byte[] displaying in Datagrid column

All columns are displaying correctly in the DataGrid except for one. 除其中一列外,所有列均在DataGrid中正确显示。 I ran this sql query in MySqlWorkbench and it works so there is nothing wrong with that: 我在MySqlWorkbench中运行了此sql查询,它可以正常工作,因此没有任何问题:

  string query = @"SELECT c.*,cc.CountryName ,(Select UserName FROM users WHERE User_ID = c.CreatedByUser) AS CreatedBy,
                      (select GROUP_CONCAT(AreaDescription) from pxpcountycodes where countyid=c.id) as AreaDescription, 
                      (select GROUP_CONCAT(cmr.AccountCode)) as Member  " +
                    " FROM counties c " +
                    " LEFT JOIN Countries cc ON c.CountryID = cc.ID " +
                    " LEFT JOIN PXPCountyCodes PXPc on c.ID = PXPc.CountyID" +
                    " LEFT JOIN customer cmr ON PXPc.MemberID = cmr.ID  " +
                    " WHERE c.Company_ID = ?companyID ";

And the code for the DataGrid: 以及DataGrid的代码:

<asp:DataGrid runat="server" CssClass="tblResults" OnItemDataBound="dgList_ItemCreated" AllowSorting="true" OnSortCommand="dgList_Sort" ID="dgList" DataKeyField="ID" AutoGenerateColumns="false">
                <HeaderStyle CssClass="tblResultsHeader" />
                <AlternatingItemStyle BackColor="#EEEEEE" />
                <Columns>
                    <asp:BoundColumn DataField="CountyName" HeaderText="County Name/PostCode" SortExpression="c.CountyName" ></asp:BoundColumn>
                    <asp:BoundColumn DataField="Description" HeaderText="Description" SortExpression="c.Description"></asp:BoundColumn>   
                    <asp:BoundColumn DataField="Member" HeaderText="Member" SortExpression="Member"/> 
                    <asp:BoundColumn DataField="CountryName" HeaderText="Country" SortExpression="cc.CountryName"></asp:BoundColumn>                   
                    <asp:BoundColumn DataField="CountyPostCode" HeaderText="County/PostCode" SortExpression="c.CountyPostCode"></asp:BoundColumn>   
                    </Columns>
            </asp:DataGrid>

The problem is with the Member column. 问题出在Member栏。 This column displays a list of companies, so for example the column should display CONWAY,NGWCLARE . 此列显示公司列表,例如,该列应显示CONWAY,NGWCLARE Some columns are trying to display around 5 companies so is the length causing a problem? 一些列试图显示大约5家公司,所以长度会引起问题吗?

Code behind Grid: 网格背后的代码:

DataSet ds = Lookups.County.GetAllCounties(Company.Current.CompanyID, ddlSearchBy.SelectedItem.Value, txtSearchBy.Text, IsActive, rbl_both.Checked, OrderBy, false, -1, "", 0);

        if (ds.Tables[0].Rows.Count > 0)
        {
            dgList.DataSource = ds.Tables[0];
            dgList.DataBind();
        }

Try this query. 试试这个查询。 CASTing GROUP_CONCAT's output AS CHAR should fix the issue. 放空GROUP_CONCAT的输出AS CHAR应该可以解决此问题。

 string query = @"SELECT c.*,cc.CountryName ,(Select UserName FROM users WHERE User_ID = c.CreatedByUser) AS CreatedBy,
                      (select GROUP_CONCAT(AreaDescription) from pxpcountycodes where countyid=c.id) as AreaDescription, 
                      CAST(GROUP_CONCAT(cmr.AccountCode) As CHAR) as Member  " +
                    " FROM counties c " +
                    " LEFT JOIN Countries cc ON c.CountryID = cc.ID " +
                    " LEFT JOIN PXPCountyCodes PXPc on c.ID = PXPc.CountyID" +
                    " LEFT JOIN customer cmr ON PXPc.MemberID = cmr.ID  " +
                    " WHERE c.Company_ID = ?companyID ";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM