简体   繁体   English

在Asp.Net中下载表格中的选项

[英]Download Option In Table In Asp.Net

i try to disable/hide or don't want to show download option in reject document like this 我尝试禁用/隐藏或不想在这样的拒绝文档中显示下载选项

this is want i want 这是我想要的

              doc id doc name file uplaoded uploaded date department   status 
 download     1    analysis  abc.docx    12-12-2013   finance        approve
              2    report fm  fm.docx    14-06-2013   finance         reject
 download     3    report ibf  ibf.docx    14-06-2013   finance        approve
              4    report ma  ma.docx    14-06-2013   finance         reject

now in reject row i don't want to show download option because this is rejected documents here is code which i try 现在在拒绝行我不想显示下载选项,因为这是被拒绝的文件这里是我尝试的代码

        protected void Repeater4_ItemDataBound(object sender, RepeaterItemEventArgs e)
       {

        //DataRowView theDataRowView = e.Item.DataItem as DataRowView;
        //theDataRowView.Row["Status"] == "Status";

        // Only look in data rows, ignore header and footer rows
        if (e.Item.ItemType == ListItemType.AlternatingItem ||
         e.Item.ItemType == ListItemType.Item)
         {
            // Get a data view row object so we can reference the data 
            // in the repeater by the bound field names      
            DataRowView theDataRowView = e.Item.DataItem as DataRowView;
            //theDataRowView.Row["Status"] == "Status";

            // Make sure we got the data row view before we try to use it
            if (theDataRowView != null)
            {
                // Get the value of status from the control that holds the value
                string theStatus = theDataRowView.Row["Status"].ToString();

                // Find the download link control
                LinkButton theLinkButtonDownload = e.Item.FindControl("LinkButton2")
             as LinkButton;

                if (theStatus.ToUpper() == "APPROVE")
                {
                    if (theLinkButtonDownload != null)
                    {
                        theLinkButtonDownload.Visible = true;
                    }
                }
                else
                {
                    if (theLinkButtonDownload != null)
                    {
                        theLinkButtonDownload.Visible = false;
                    }
                    }
                  }
                }


           }

this is html 这是HTML

         <div class="CSSTableGenerator">
                <table border="0" width="100%" cellpadding="0" cellspacing="0" 
                      id="results">

                    <asp:Repeater ID="Repeater4" OnItemCommand="Repeater4_ItemCommand" 
                    runat="server">
                        <HeaderTemplate>
                            <tr>
                            <td>
                            </td>

                                <td>
                                </td>
                                <td>
                                    Document ID
                                </td>
                                <td>
                                    Document Name
                                </td>
                                <td>
                                    File Uploaded
                                </td>
                                 <td>
                                   Uploaded By
                                </td>
                                <td>
                                    Document Type
                                </td>
                                <td>
                                    Department Type
                                </td>
                                <td>
                                    Approve Name
                                </td>
                            </tr>
                        </HeaderTemplate>
                        <ItemTemplate>
                            <tr>
                             <td>

                            <asp:HiddenField ID="HiddenField1" runat="server" 
                          Value='<%#DataBinder.Eval(Container.DataItem, "Status")%>'/>

                            </td>
                            <td>
                            <asp:LinkButton ID="LinkButton2" runat="server" 
                           CommandArgument='<%# Eval("FileUploaded") %>'

                            CommandName="download" Visible='<%# 
                         Convert.ToString(Eval("Status")).ToUpper() != "Reject" %>' 
                      Text="Download" />


                            </td>


                              <%--  <td>
                                    <asp:LinkButton ID="LinkButton1" runat="server" 
                            CommandArgument='<%# Eval("FileUploaded") %>'
                                        CommandName="download" 
                                >Download</asp:LinkButton>
                                </td>--%>
                               <td>

                      <%#DataBinder.Eval(Container.DataItem,"DocumentID") %>
                                </td>
                                <td>
                                    <%#DataBinder.Eval(Container.DataItem, 
                                     "DocumentName")%>
                                </td>
                                <td>
                                    <%#DataBinder.Eval(Container.DataItem, 
                        "FileUploaded")%>
                                </td>
                                <td>
                                    <%#DataBinder.Eval(Container.DataItem, 
                             "UploadedBy")%>
                                </td>
                                <td>
                                    <%#DataBinder.Eval(Container.DataItem, 
                                    "Document")%>
                                </td>
                                <td>
                                    <%#DataBinder.Eval(Container.DataItem, 
                   "Department")%>
                                </td>
                                <td>
                                    <%#DataBinder.Eval(Container.DataItem, "Status")%>
                                </td>
                            </tr>
                        </ItemTemplate>
                    </asp:Repeater>
                </table>
            </div>

i try code which i posted and it can not show me any error but it always show me download visible in rejected document and i want to in rejected documents dowload option dont want to show 我尝试我发布的代码,它不能告诉我任何错误,但它总是显示我在拒绝的文档中可见下载,我想在拒绝的文件下载选项不想显示

因为您使用ToUpper ,请与大写字符串值进行比较,如下所示

Visible='<%#Convert.ToString(Eval("Status")).ToUpper() != "REJECT" %>' 

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

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