gpt4 book ai didi

c# - System.Byte[] 显示在 Datagrid 列中

转载 作者:行者123 更新时间:2023-11-29 11:49:58 25 4
gpt4 key购买 nike

除一列外,所有列均在 DataGrid 中正确显示。我在 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 ";

以及 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>

问题出在 Member 列上。此列显示公司列表,因此该列应显示 CONWAY,NGWCLARE。有些栏目试图显示大约 5 家公司,那么长度是否会导致问题?

网格背后的代码:

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();
}

最佳答案

尝试这个查询。将 GROUP_CONCAT 的输出转换为 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 ";

关于c# - System.Byte[] 显示在 Datagrid 列中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34264653/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com