简体   繁体   English

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

[英]change hyperlink asp.net depend result column in gridview

Good afternoon, I have a gridview (resume of the gridview) 下午好,我有一个gridview(恢复gridview)

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

I wish that when the result appears in column PROJECT - ASG (from table Projet.strNom) for example it becomes a HyperLinkField which would refer to a page "ActionASG.aspx? IDEntretien = {0}". 我希望当结果出现在例如PROJECT-ASG列(来自表Projet.strNom)中时,它成为一个HyperLinkField,它将引用页面“ ActionASG.aspx?IDEntretien = {0}”。 If the result changes, for example AEPP it would refer to "ActionAEPP.aspx? IDEntretien = {0}". 如果结果发生更改,例如AEPP,它将引用“ ActionAEPP.aspx?IDEntretien = {0}”。 For now, the column is as follows: It should therefore be changed. 现在,该列如下:因此,应对其进行更改。 ???Datanavigateurlfields = "strNom" changes depending on the content, it refers to a very specific page. Datanavigateurlfields =“ strNom”根据内容而变化,它指的是一个非常特定的页面。

I just program in C # and I hope I was clear. 我只是用C#编程,希望我很清楚。 In all cases a big thank you. 在任何情况下都非常感谢。

leerickx 里里克斯

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM