<td>小用法合集</td>

1、添加lable显示状态等

<td>
          <asp:Label ID="Label1" runat="server"  Text='<%# showChief(Eval("chief").ToString()) %>'></asp:Label>
 </td>

数据库中查找

public string showChief(string chief)
        {
            string Crew_Chief = null;
            object name = fc.selectCrewName(chief);
            if (name != "" && name != null)
            {
                Crew_Chief = name.ToString();
            }
            return Crew_Chief;
        }

直接根据数字显示状态

public string showState(string state)
        {
            string strIsType = null;
            switch (state)
            {
                case "0":
                    strIsType = "未操作";
                    break;
                case "1":
                    strIsType = "已提交至OA";
                    break;
                default:
                    strIsType = "忽略";
                    break;
            }
            return strIsType;
        }


2、简单的跳转页面,可传多个参数,也可使用LinkButton

 <td>
   <a href="FlightLog.aspx?link=<%#Eval("crew_link_line") %>&chief_code=<%#Eval("p_code") %>&chief_name=<%#Eval("c_name") %>" target=_blank>打分</a>
</td>


3、页面跳转,根据状态判断是否显示链接文字(例:若isShow()==0,则显示”出现异常“,可点击该词跳转链接,否则不显示)

<td>
  <a href="IncomeInfo.aspx?ORDER_CODE=<%#Eval("merchant_order_id") %>" target=_blank><%# isShow(Eval("is_match2").ToString()) == "0" ? "出现异常!" : ""%></a>   </td>


4、Repeater中本页面弹出窗口点击确定删除记录

需要添加HiddenField记录ID,repeater添加onitemcommand="RP_Main_ItemCommand"方法,添加LinkButton,其中有CommandName="Del"
<asp:Repeater ID="RP_Main" runat="server"  onitemcommand="RP_Main_ItemCommand">
<ItemTemplate>
   <tr class="One" style="FONT-WEIGHT: normal; FONT-STYLE: normal; BACKGROUND-COLOR: white; TEXT-DECORATION: none">
       <td><%#Eval("kind_name")%></td>
       <td><%#Eval("remark")%></td>
       <td> 
           <asp:HiddenField ID="kind_id" runat="server" Value='<%#Eval("kind_id") %>' />
           <asp:LinkButton ID="LB_Del" CommandName="Del" runat="server" OnClientClick="return confirm( '你确定要删除这条记录吗? ');">删除</asp:LinkButton>
        </td>
     </tr>
</ItemTemplate>
</asp:Repeater>

protected void RP_Main_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandName == "Del")
            {
                HiddenField hiddentext = (HiddenField)e.Item.FindControl("kind_id");
                string kind_id = hiddentext.Value.ToString();
                DataSet ds1 = s.SelectKind(kind_id);
                if (ds1.Tables[0].Rows.Count <= 0)
                {
                    s.DeleteKind(kind_id);
                    string jsStr = "<script>alert('删除成功!')</script>";
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", jsStr, false);
                    Show();
                }
                else
                {
                    string jsStr = "<script>alert('对不起,该类型已使用所以不可删除!')</script>";
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", jsStr, false);
                }
            }
        }



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值