在 GridView 中更改超链接 asp.net 依赖于结果列



下午好,我有一个网格视图(网格视图的简历)

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
        DataKeyNames="IDEntretien,Expr2,Expr3" DataSourceID="SqlDataSource12" 
        EnableModelValidation="True" BackColor="White" BorderColor="#999999" 
        BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Vertical">
        <AlternatingRowStyle BackColor="Gainsboro" />
        <Columns>
            <asp:BoundField DataField="IDEntretien" HeaderText="IDEntretien" 
                InsertVisible="False" ReadOnly="True" SortExpression="IDEntretien" 
                Visible="False" />
            <asp:BoundField DataField="IDPersonne" HeaderText="ID" 
                SortExpression="IDPersonne" />
            <asp:BoundField DataField="dtmDate" HeaderText="Date" 
                SortExpression="dtmDate" DataFormatString="{0:d}" />
            <asp:BoundField DataField="strNom" HeaderText="Projet" 
                SortExpression="strNom" />
            <asp:HyperLinkField DataNavigateUrlFields="IDEntretien" 
                DataNavigateUrlFormatString="ActionASG.aspx?IDEntretien={0}" HeaderText="ASG" 
                Text="ASG" />
            <asp:HyperLinkField DataNavigateUrlFields="IDEntretien" 
                DataNavigateUrlFormatString="ActionAEPP.aspx?IDEntretien={0}" HeaderText="AEPP" 
                Text="AEPP" />
        </Columns>
        <FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
        <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
        <RowStyle BackColor="#EEEEEE" ForeColor="Black" />
        <SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
    </asp:GridView>
<asp:SqlDataSource ID="SqlDataSource12" runat="server" 
        ConnectionString="<%$ ConnectionStrings:BE Intranet 2009 01 %>" 
        SelectCommand="SELECT Entretien.IDEntretien, Entretien.IDConseiller, Entretien.IDPersonne, Entretien.dtmDate, Entretien.memCommentaires, Entretien.IDProjet, Projet.strNom, Conseiller.strNom AS Expr1, Conseiller.IDConseiller AS Expr2, Projet.IDProjet AS Expr3 FROM Entretien INNER JOIN Conseiller ON Entretien.IDConseiller = Conseiller.IDConseiller INNER JOIN Projet ON Entretien.IDProjet = Projet.IDProjet WHERE (Entretien.IDPersonne = @IDPersonne)">
        <SelectParameters>
            <asp:QueryStringParameter Name="IDPersonne" QueryStringField="IDP" />
        </SelectParameters>
    </asp:SqlDataSource>

例如,我希望当结果出现在列PROJECT - ASG(来自表Projet.strNom)中时,它变成了一个超链接字段,它将引用页面"ActionASG.aspx?IDEntretien = {0}"。如果结果发生变化,例如 AEPP,它将引用"行动AEPP.aspx?IDEntretien = {0}"。目前,该列如下所示:因此,应该加以改变。???Datanavigateurlfields = "strNom" 根据内容而变化,它指的是一个非常具体的页面。

我只是用 C# 编程,我希望我很清楚。在所有情况下,非常感谢。

里克克斯

在网格的数据行绑定事件中访问网格列,并根据链接按钮的数据更改 int url

相关内容

最新更新