Click here to Skip to main content
15,904,024 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i try to not show download linkbutton when status is in pedning. when user upload document then in repeater i set status pending

and when approve then i show download link visible and also when document reject then i not show download link

but this is not work for pending

here is code

C#
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {


            if (e.Item.ItemType == ListItemType.AlternatingItem ||
           e.Item.ItemType == ListItemType.Item)
            {

                DataRowView theDataRowView = e.Item.DataItem as DataRowView;


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

                    else
                    {
                        if (theLinkButtonDownload != null)
                        {
                            theLinkButtonDownload.Visible = false;
                        }
                    }

                }
            }



html
XML
<div align="center" class="down">
        <br />
        <br />
        <center>
            <div class="vpb_main_wrapper3" top="20" align="center" style="left: inherit" />
            <br clear="all" />
            <h1 align="center" class="adminlabel">
           YOUR DOCUMENTS</h1>
            <hr /><hr /><hr /><br /><br />
            <div>

                <div class="CSSTableGenerator">
                    <table border="0" width="100%" cellpadding="0" cellspacing="0" id="results">
                        <asp:Repeater ID="Repeater1" OnItemCommand="Repeater1_ItemCommand" runat="server">
                            <HeaderTemplate>
                                <tr>

                                    <td>
                                    </td>
                                    <%--<td>
                                        Document ID
                                    </td>--%>
                                    <td>
                                        Document Name
                                    </td>
                                    <td>
                                        File Uploaded
                                    </td>
                                    <td>
                                        Uploaded Date
                                    </td>
                                   <%-- <td>
                                        Document Type
                                    </td>--%>
                                    <td>
                                        Department Type
                                    </td>
                                    <td>
                                        Approve Name
                                    </td>
                                </tr>
                            </HeaderTemplate>
                            <ItemTemplate>
<%--                        <tr class="<%# (bool) DataBinder.Eval(Container.DataItem, "ViewedID") == "1" ? "highlight" : string.Empty %>">
--%>
<%--                             <tr style='background-color: <%# (bool) DataBinder.Eval(Container.DataItem, "ViewedID") ? "yellow" : "white" %>'>
--%>
                                    <tr>


                                    <%-- <td>

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

                                </td>--%>
                                    <td>
                                        <asp:LinkButton ID="LinkButton1" runat="server" CommandArgument='<%# Eval("FileUploaded") %>'
                                            CommandName="download"  Visible='<%#Convert.ToString(Eval("Status")).ToUpper() != "REJECT" %>' >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, "UploadedDate")%>
                                    </td>
                                    <%--<td>
                                        <%#DataBinder.Eval(Container.DataItem, "Document")%>
                                    </td>--%>
                                    <td>
                                        <%#DataBinder.Eval(Container.DataItem, "Department")%>
                                    </td>
                                    <td>
                                        <%#DataBinder.Eval(Container.DataItem, "Status")%>
                                    </td>
                                </tr>
                            </ItemTemplate>
                            <FooterTemplate>
                            </table>
                            </FooterTemplate>
                        </asp:Repeater></table>

                     <div style="overflow: hidden;">
        <asp:Repeater ID="rptPaging" runat="server" onitemcommand="rptPaging_ItemCommand">
            <ItemTemplate>
                                <asp:LinkButton ID="btnPage"
                 style="padding:8px; margin:2px; background:#20B2AA; border:solid 1px #666; font:8pt tahoma;"
                CommandName="Page" CommandArgument="<%# Container.DataItem %>"
                 runat="server" ForeColor="White" Font-Bold="True"><%# Container.DataItem %>
                                </asp:LinkButton>
           </ItemTemplate>
        </asp:Repeater>
        </div>
                </div>
            </div>
        </center>



here is the image

image[^]




how i will not show download link when status is in pending
Posted
Updated 9-Feb-14 9:36am
v2
Comments
Ahmed Bensaid 9-Feb-14 14:51pm    
Your "theLinkButtonDownload" variable seems to be null in your PENDING case ...
Diya Ayesa 9-Feb-14 14:56pm    
so what i do>?
Ahmed Bensaid 9-Feb-14 15:28pm    
Can I see your entire code-behind and markup files ?
Diya Ayesa 9-Feb-14 15:37pm    
see update question please
Ahmed Bensaid 9-Feb-14 15:56pm    
Ok, you need to replace this condition in markup :
<%#Convert.ToString(Eval("Status")).ToUpper() != "REJECT" %>
By :
<%#Convert.ToString(Eval("Status")).ToUpper() == "APPROVE" %>
So, with that, you won't need to manipulate Visible property in code behind anymore.

1 solution

Ok, you need to replace this condition in markup :
VB
<%# Convert.ToString(Eval("Status")).ToUpper() != "REJECT" %>

By :
VB
<%# Convert.ToString(Eval("Status")).ToUpper() == "APPROVE" %>

So, with that, you won't need to manipulate Visible property in code behind anymore.
 
Share this answer
 
v6

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900