简体   繁体   中英

ASP.NET C# Gridview Cell URL Parameter

ok the following is the code for the gridview:

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
    BorderColor="#3399FF" BorderStyle="Solid" CellPadding="10" CellSpacing="10" 
    DataKeyNames="Request_No" DataSourceID="SqlDataSource1" ForeColor="#3399FF" 
    HorizontalAlign="Center">
    <Columns>
        <asp:BoundField DataField="Request_No" HeaderText="Request No" ReadOnly="True" 
            SortExpression="Request_No" />
        <asp:BoundField DataField="Request_Details" HeaderText="Request Details" 
            SortExpression="Request_Details" />

<asp:BoundField DataField="Request_Status" HeaderText="Request Status" 
            SortExpression="Request_Status" />
    </Columns>
</asp:GridView>

I have the three columns, and I want the last column cell data to be hyperlinks. So when I press that link, it will go to another page so that I could retrieve the cell value there and call details of request from database. This is simple enough in PHP but here am not sure how :( Thanks and help is appreciated :)

To do it you need to use TemplateField instead of <asp:BoundField DataField="Request_Status" something like:

<asp:TemplateField>
    <ItemTemplate>
          <a href="requiredUrl">link text</a>
    </ItemTemplate>
</asp:TemplateField>

In order to get data binding in that template you can use Bind, Eval methods

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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