zoukankan      html  css  js  c++  java
  • 杂记

    1.在aspx页面获得索引和在.aspx.cs页面中获得记录数据的方法:

    获得索引:<%#Container.ItemIndex%>

    获得记录集数据:string classid = DataBinder.Eval(e.Item.DataItem, "ClassID").ToString();

    2.在嵌套Repeater中取得父级的Container.ItemIndex的方法:

    <%#((RepeaterItem)Container.Parent.Parent).ItemIndex%>

    3.去掉层的横向滚动条的方法:overflow-x:hidden;

    4.判断数据类型的方法:Int32.TryParse,同理还有其它如DateTime.TryParse等;

    5.SqlDataReader自动关闭与数据库自动关闭,参考:http://www.cnblogs.com/superfeeling/archive/2011/10/16/2214091.html

    6.去掉gridview中自动生成的rules属性的方法,将GridLines属性设置为none;

    7.aspx页面中如果不存在事件回发,可以去掉form标签,但要注意的是,去掉form标签后,不能通过ClientScript.RegisterStartupScript注册脚本,折中的解决办法是在aspx页面中设置一个Literal控件,然后在.aspx.cs中设置text为js脚本。

    8.在Repeateritem中如果绑定public类型的单个变量,要注意以下两点:(1)使用Page.DataBind();(2)在ItemCreated事件中编写变量的判断赋值。

    9.DataTable的选择与求和:

    DataRow[] dr1 = QuestionScore.Select("ModelID IN (" + related.Replace("|",",") + ")");

    dt.Compute("sum(hit)", "true")

    10.使用UpdatePanel局部刷新时弹出js脚本的方法:ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", MessageBox.Alert("您已经投过票了"),false);

    11.通过Response.AppendHeader("Content-Disposition", "attachment; filename=" + string.Format("{0:yyyyMMddhhmmss}",DateTime.Now) + System.IO.Path.GetExtension(DownLoad));可以在下载时改变下载文件的文件名;

  • 相关阅读:
    满屏品字布局怎么设计
    Web前端面试题(二)
    Welcome-to-Swift-11方法(Methods)
    Welcome-to-Swift-10属性 (Properties)
    Welcome-to-Swift-09类和结构体(Classes and Structures)
    Welcome-to-Swift-08枚举 (Enumerations)
    Welcome-to-Swift-07闭包(Closures)
    Welcome-to-Swift-06函数(Functions)
    Welcome-to-Swift-05控制流(Control Flow )
    Welcome-to-Swift-04集合类型(Collection Types)
  • 原文地址:https://www.cnblogs.com/superfeeling/p/2181487.html
Copyright © 2011-2022 走看看