2016-08-15 153 views
0

我想通过向导插入超链接字段。但是当我运行应用程序时,我用蓝色链接获得文本,但它不可点击。Gridview超链接不工作

这是我的代码:

<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" CellPadding="4" DataKeyNames="stepID" DataSourceID="SqlDataSource1" ForeColor="#333333" GridLines="None"> 
    <AlternatingRowStyle BackColor="White" /> 
    <Columns> 
     <asp:HyperLinkField DataNavigateUrlFields="stepID,stepName,stepStartdate,stepEndDate,stageID" DataNavigateUrlFormatString="~/Supervisor/editSteps.aspx?stepID={0}&amp;stepName={1}&amp;Sdate={2}&amp;EDate={3}&amp;stgD={4}" DataTextField="stepName" /> 
     <asp:BoundField DataField="stageID" HeaderText="stageID" SortExpression="stageID" /> 
     <asp:BoundField DataField="stepStartdate" HeaderText="stepStartdate" SortExpression="stepStartdate" /> 
     <asp:BoundField DataField="stepEndDate" HeaderText="stepEndDate" SortExpression="stepEndDate" /> 
    </Columns> 
    <EditRowStyle BackColor="#2461BF" /> 
    <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" /> 
    <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" /> 
    <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" /> 
    <RowStyle BackColor="#EFF3FB" /> 
    <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" /> 
    <SortedAscendingCellStyle BackColor="#F5F7FB" /> 
    <SortedAscendingHeaderStyle BackColor="#6D95E1" /> 
    <SortedDescendingCellStyle BackColor="#E9EBEF" /> 
    <SortedDescendingHeaderStyle BackColor="#4870BE" /> 
</asp:GridView> 
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:DefaultConnection %>" SelectCommand="SELECT * FROM [tblsteps] WHERE ([stageID] = @stageID)"> 
    <SelectParameters> 
     <asp:QueryStringParameter Name="stageID" QueryStringField="StgID" Type="Int32" /> 
    </SelectParameters> 
</asp:SqlDataSource> 

没有错误或警告,当我运行该应用程序。

+1

[C#中的GridView超链接字段]的可能的复制(http://stackoverflow.com/questions/12823422/gridview-hyperlink-field-in-c-sharp) – MethodMan

回答

0

您的代码看起来不错,我测试了它并且超链接正在工作。我怀疑超链接是通过JavaScript或CSS禁用的。

您可以通过暂时从相关页面中删除所有CSS和JavaScript引用来进行确认。

如果它是一个的禁用的超级链接,您可以通过以下步骤,当您在浏览器中运行Web页面检查超链接的样式CSS:

  1. 在Gooogle企业的Chrome
  2. 按运行你的网页Ctrl+Shift+I调出HTML检查控制台
  3. 找到HTML中的超链接(该<a>元素)
  4. 检查其禁用元素的样式规则,并从你的CSS文件中删除:

Inspecting HTML in Google Chrome