2013-08-17 21 views
0

我正在一個asp.net頁面上工作。我有一個objectdatasource和一個gridview。 gridview有兩列。 objectdatasource返回一個包含5行的數據表。我想是示出gridview的第5行的情況下,ActionReportsShowTotalHF其用於創建超鏈接navigateurl應具有值1,否則它應具有值0:將不同的值傳遞給gridview超鏈接

<asp:ObjectDataSource ID="ActionReportsODS" runat="server" TypeName="HRcomgeWebApp.Old_App_Code.DataLayer.HRActionLog" SelectMethod="GenerateReports"> 
            <SelectParameters> 
             <asp:ControlParameter Name="dateFrom" Type="DateTime" ControlID="ActionReportsFromTextBox" PropertyName="Text" ConvertEmptyStringToNull="true" /> 
             <asp:ControlParameter Name="dateTo" Type="DateTime" ControlID="ActionReportsToTextBox" PropertyName="Text" ConvertEmptyStringToNull="true" /> 
             <asp:ControlParameter Name="companyId" Type="Int32" ControlID="ActionReportsCompaniesDDL" PropertyName="SelectedValue" ConvertEmptyStringToNull="true" /> 
             <asp:ControlParameter Name="registrantId" Type="Int32" ControlID="ActionReportsRegistrantIDHF" PropertyName="Value" ConvertEmptyStringToNull="true" /> 
             <asp:ControlParameter Name="vacancyId" Type="Int32" ControlID="ActionReportsVacancyIDHF" PropertyName="Value" ConvertEmptyStringToNull="true" /> 
            </SelectParameters> 
           </asp:ObjectDataSource> 
           <asp:GridView ID="gvActionReports" runat="server" SkinID="SmallListGridView" AutoGenerateColumns="False" EnableViewState="false" DataSourceID="ActionReportsODS"> 
            <Columns> 
             <asp:BoundField DataField="Data" HeaderText="<%$ Resources:AdminStatistics, HeaderData %>" /> 
             <asp:TemplateField HeaderText="<%$ Resources:AdminStatistics, HeaderCount %>" 
              ItemStyle-HorizontalAlign="Right" > 
              <ItemTemplate> 
               <asp:HyperLink ID="ShowDetailsHL" runat="server" Text='<%# Eval("Counts") %>' Visible='<%# Eval("Counts").ToString() != "0" %>' 
                NavigateUrl='<%# GetActionLogsDetailScript(Eval("Action").ToString()) %>' /> 

               <asp:Literal ID="CountLiteral" runat="server" Text='<%# Eval("Counts") %>' Visible='<%# Eval("Counts").ToString() == "0" %>' /> 
              </ItemTemplate> 
             </asp:TemplateField> 
            </Columns> 
           </asp:GridView> 

這裏是方法的定義:

protected string GetActionLogsDetailScript(string action) 
     { 
      return String.Format("JavaScript:OpenWindow('{0}?{1}={2}&{3}={4}&{5}={6}&{7}={8}&{9}={10}&{11}={12}&{13}={14}', 800, 600);", 
       this.ResolveUrl(GlobalVariables.Page_ActionLogs), 
       GlobalVariables.QueryString_Action, 
       action, 
       GlobalVariables.QueryString_DateFrom, 
       ActionReportsFromTextBox.Text, 
       GlobalVariables.QueryString_DateTo, 
       ActionReportsToTextBox.Text, 
       GlobalVariables.QueryString_CompanyID, 
       ActionReportsCompaniesDDL.SelectedValue, 
       GlobalVariables.QueryString_RegistrantID, 
       ActionLogsRegistrantIDHF.Value, 
       GlobalVariables.QueryString_VacancyID, 
       ActionReportsVacancyIDHF.Value, 
       GlobalVariables.QueryString_ShowTotal, 
       ActionReportsShowTotalHF.Value 
      ); 
     } 

回答

0

試試這個

display:none;

<asp:HyperLink ID="ShowDetailsHL" runat="server" Text='<%# Eval("Counts") %>' <%# Eval("Counts").ToString() != "0" ? "" :"style='display:none;'"%> 
                NavigateUrl='<%# GetActionLogsDetailScript(Eval("Action").ToString()) %>' /> 
+0

我不想隱藏的超級鏈接,我想這裏面產生的URL,這個超級鏈接應該值1時,將顯示爲參數GlobalVariables.QueryString_ShowTotal這是從隱藏字段填充網格的最後一排的方法GetActionLogsDetailScript ActionReportsShowTotalHF – DotnetSparrow