我有一个带有预定义列和一个selectcommand的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 %>" />
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; }