gpt4 book ai didi

c# - 如何按标题对数据进行分组?

转载 作者:太空狗 更新时间:2023-10-29 22:00:09 33 4
gpt4 key购买 nike

我有一个 SQL 表:

ID || Title  || FileName || Extension || FileContent

1 || flower ||rose || jpg || binary data

2 || flower ||tulip || jpg || binary data

3 || cats ||black-c || png || binary data

4 || cats ||White-c || jpg || binary data

5 || Dogs ||Brown-d || jpg || binary data

我想在一行中显示所有具有相同标题的图片。因此,例如,标题花包含图片等。

我还有一个 GridView :

<asp:GridView ID="GridView1" CssClass="gridview" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" OnRowDataBound="RowDataBound" Width="100%"  GridLines="None" SelectedRowStyle-BackColor="#a8c066" runat="server" AutoGenerateColumns="False" DataKeyNames="ID">
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID" ReadOnly="True" Visible="false" />
<asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
<asp:BoundField DataField="FileName" HeaderText="FileName" SortExpression="FileName" />
<asp:BoundField DataField="FileContent" HeaderText="FileContent" SortExpression="FileContent" visible="false" />
</Columns>
</asp:Gridview>

所以我的目标是选择一行并单击它。如果所选行的标题是“花”,那么它应该加载 2 个图像。

我已经做过/尝试过的事情

 protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
GridView listBox = sender as GridView;
int selectedID = Int32.Parse(listBox.SelectedDataKey.Value.ToString());
LoadDetail(selectedID);
}

 void LoadDetail(int id)
{

List<Pic> sb = (from x in myEnt.Pic where x.ID == id select x).ToList();

lblTitle.Text = String.Join(", ", sb.Select(x => x.Title));
Img1.ImageUrl = "data:Image/jpg;base64," + String.Join(", ", sb.Select(x => Convert.ToBase64String((byte[])x.FileContent)));
}

它只显示一张图片,(因为选择了 id)但我也不知道如何提及标题。提前致谢!

最佳答案

尝试在 DataKeys 中使用两列:

DataKeyNames="ID,Title">

var id = listBox.DataKeys[listBox.SelectedIndex].Values["ID"];
var title = listBox.DataKeys[listBox.SelectedIndex].Values["Title"];

关于c# - 如何按标题对数据进行分组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40785626/

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