我已将div
与条件..放在我的执行上,如果还显示条件,我需要将其删除..
**My New Code**
<asp:TemplateField HeaderStyle-Width="90px" ItemStyle-Width="0">
<ItemTemplate>
<div style="cursor: pointer; padding-top: 02px;" onclick="ShowfllDetails(<%#Eval("StudentID")%>);">
if(<%# (Eval("StatusName").Equals("Processed")) %>)
{
//should not show the upload button
}
else
{
<u>Upload </u> //show the upload button
}
</div>
<asp:Image ID="Image1" runat="server" ImageUrl='<%#(Eval("StatusName").Equals("Processed") ? "images/add_btn.png" : "")%>' />
</ItemTemplate>
我正在显示if条件我不需要显示它..
感谢您。
答案 0 :(得分:0)
我在Gridview中做了这样的功能,我假设你也在做同样的事情。您可以使用linkbutton set commandArgument和Commandname属性代替标记。在触发Gridview_Rowcommand事件之后。当您点击链接按钮时,此事件将触发,您可以在数据库或会话中的某个位置设置状态,以便针对学生ID点击此链接
<asp:LinkButton ID="LinkButton1" runat="server" Text="Upload" CommandName="Upload"
CommandArgument='<%#Eval("StudentID")%>'></asp:LinkButton>
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Upload")
{
// get student id against clicked link button
int studentid = Convert.ToInt16(e.CommandArgument);
// -- set status in database it is clicked
}
}
此绑定后,您的网格和rowdatabound查找控件并将可见性设置为true或false(已处理/未处理)
绑定你的&#34; StatusName&#34;数据库字段到标签并将标签的可见性设置为false,以便它不应显示。
现在从以下代码中了解
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
// Display the company name in italics.
Label lblAssignto = (Label)e.Row.FindControl("lblassignto");
LinkButton addevent = (LinkButton)e.Row.FindControl("lnkBtnAddEvent");
LinkButton showevent = (LinkButton)e.Row.FindControl("lnkBtnShowEvent");
if (string.IsNullOrEmpty(lblAssignto.Text))
{
addevent.Visible = false;
showevent.Visible = false;
}
else
{
addevent.Visible = true;
showevent.Visible = true;
}
}
}