我尝试禁用/隐藏或不想在拒绝文档中显示下载选项,如此
这是我想要的
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
现在在拒绝行中我不想显示下载选项,因为这是被拒绝的文件,这里是我尝试的代码
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;
}
}
}
}
}
这是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>
我尝试我发布的代码并且它无法向我显示任何错误但它总是显示我在被拒绝的文档中可见下载并且我想在拒绝的文档下载选项不想显示
答案 0 :(得分:2)
因为您使用ToUpper
,请与大写字符串值进行比较,如下所示
Visible='<%#Convert.ToString(Eval("Status")).ToUpper() != "REJECT" %>'