如何使用如果aspx页面状态 [英] how to use if condition in aspx page

查看:120
本文介绍了如何使用如果aspx页面状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经把 DIV 与条件..在我执行,如果还显示状态,我需要将其删除。

I had placed div with condition.. on my execution,if condition is also displayed, i need to remove it..

        **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条件,我需要为不显示它..


I'm getting displayed the if condition i need not to display it..

感谢信。

推荐答案

我已经做了内部的GridView这样的功能,我假设你正在做的一样。代替标签可以使用的LinkBut​​ton设置commandArgument和的CommandName属性。之后,消防Gridview_Rowcommand事件。当过,你会点击LinkBut​​ton的这一事件将触发,您可以在会话设置状态数据库或其他地方,这个链接被点击针对学生证

I have done such a functionality inside Gridview, I assume you are doing the same. In place of tag you can use linkbutton set commandArgument and Commandname properties. AFter that fire Gridview_Rowcommand event. when ever you will click on linkbutton this event will fire and you can set the status in database or somewhere in session that this link is clicked against student 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(加工/不处理)

after this bind your grid and on rowdatabound find control and set the visibility to true or false (Processed/Not Processed)

您绑定StatusName的数据库字段添加到标签和可见性设置为false标签,所以它不应该显示。

Bind your "StatusName" database field to a label and set the visibility to false of Label so that it should not display.

现在采取的想法从下面code

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

这篇关于如何使用如果aspx页面状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆