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));可以在下载时改变下载文件的文件名;

  • 相关阅读:
    solr6.0学习
    shell定时任务
    LINUX调优
    OnlineJudge大集合
    [GRYZ2015]快排练习
    [洛谷1240]诸侯安置
    [NOI导刊2011]影像之结构化特征
    手把手教你写对拍程序(PASCAL)
    [NOIP2013]转圈游戏
    [GRYZ2015]阿Q的停车场
  • 原文地址:https://www.cnblogs.com/superfeeling/p/2181487.html
Copyright © 2011-2022 走看看