0

我正在处理一个 asp.net 页面。我有一个objectdatasource 和一个gridview。gridview 有两列。objectdatasource 返回一个包含 5 行的数据表。我希望当显示gridview的第5行时,用于创建超链接navigationurl的ActionReportsShowTotalHF应该有值1,否则它应该有值0:

<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
            );
        }
4

1 回答 1

0

尝试这个

显示:无;

<asp:HyperLink ID="ShowDetailsHL" runat="server" Text='<%# Eval("Counts") %>'  <%# Eval("Counts").ToString() != "0" ? "" :"style='display:none;'"%> 
                                                    NavigateUrl='<%# GetActionLogsDetailScript(Eval("Action").ToString()) %>' />
于 2013-08-17T11:06:34.120 回答