gpt4 book ai didi

c# - 如何避免双列(预定义列+ selectcommand)?

转载 作者:太空狗 更新时间:2023-10-29 21:14:41 24 4
gpt4 key购买 nike

我有一个带有预定义列和一个选择命令的 GridView 。为什么我得到两次列?我想保留预定义的列和 select 命令,但要避免将列加倍。

<asp:GridView ID="gvMeldingen" runat="server" 
AllowSorting="True" DataSourceID="MyDataSource"
onselectedindexchanged="GridView_SelectedIndexChanged"
AutoGenerateSelectButton="True">
<Columns>
<asp:BoundField DataField="Melder" HeaderText="Melder" />
<asp:BoundField DataField="Onderwerp" HeaderText="Onderwerp" />
<asp:TemplateField HeaderText="Omschrijving">
<ItemTemplate>
<div style="overflow:auto; width: 500px; height: 150px;">
<asp:Label ID="lblOmschrijving" runat="server" Text='<%# Bind("Omschrijving")%>'></asp:Label>
</div>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Fasedatum" HeaderText="Fasedatum" />
<asp:BoundField DataField="Niveau 1" HeaderText="Niveau 1" />
<asp:BoundField DataField="Niveau 2" HeaderText="Niveau 2" />
<asp:BoundField DataField="Outlook_ID" HeaderText="OutlookID" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="MyDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:HELPDESK_OUTLOOKConnectionString3 %>" />

此代码显示了我如何使用 selectcommand:

protected void MenuTabs1_MenuItemClick(object sender, MenuEventArgs e)
{
string select = @"SELECT
aanvrager.werknemersnaam AS Melder,
hd_aanvragen.aanvraag_titel AS Onderwerp,
hd_aanvragen.aanvraag_omschrijving AS Omschrijving,
hd_aanvraag_fase.fase_datum AS Fasedatum,
hd_melding_niveau_1.niveau_omschrijving AS 'Niveau 1',
hd_melding_niveau_2.niveau_omschrijving AS 'Niveau 2',
hd_aanvragen.outlook_id
FROM hd_aanvragen
INNER JOIN hd_meldingen ON hd_meldingen.melding_id = hd_aanvragen.melding_id
INNER JOIN hd_melding_niveau_1 ON hd_melding_niveau_1.niveau1_id = hd_meldingen.niveau1_id
INNER JOIN hd_melding_niveau_2 ON hd_melding_niveau_2.niveau2_id = hd_meldingen.niveau2_id
INNER JOIN hd_aanvraag_fase ON hd_aanvraag_fase.aanvraag_id = hd_aanvragen.aanvraag_id
INNER JOIN hd_statussen ON hd_statussen.status_id = hd_aanvraag_fase.status_id
INNER JOIN hd_werknemers AS oplosser ON oplosser.werknemer_Id = hd_aanvraag_fase.werknemer_Id
INNER JOIN hd_werknemers AS aanvrager ON aanvrager.werknemer_Id = hd_aanvragen.werknemer_Id
WHERE hd_statussen.status_id = ";

int index = Int32.Parse(e.Item.Value);
multiTabs1.ActiveViewIndex = index;
int status = 0;
if (index == 1)
status = 2;
else if (index == 2)
status = 16;
else if (index == 3)
status = 17;
else if (index == 4)
status = 4;
MyDataSource.SelectCommand = select + status;
}

最佳答案

您必须将值为“false”的 AutoGenerateColumns 属性添加到您的 GridView。这将使 GridView 知道在绑定(bind)过程中不应自动生成任何列。

祝你好运! :)

关于c# - 如何避免双列(预定义列+ selectcommand)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5336494/

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