asp.net技巧

    技术2022-05-12  22

    1、  Gridview 选中一行

    1: gridview中增加一列模板列,在模板列中增加linkButton, IDSelectButton CommandName="Select"text=选择

    2RowDataBound中添加如下代码:

    e.Row.Attributes.Add("onclick", ClientScript.GetPostBackClientHyperlink(e.Row.Cells[0].FindControl("SelectButton"), ""));

    3

    <style type="text/css">

            .style1

            {

                width: 170px;

                height: 492px;

            }

            .style2

            {

                height: 492px;

            }

            .style3

            {

                font-size: small;

                text-align: center;

            }

            .style4

            {

                height: 33px;

                font-size: small;

            }

            .style5

            {

                font-size: small;

            }

           

            .style6

            {

              visibility:hidden;

              width:0;

            }

          

        </style>

       4:把linkButton的按扭用css隐藏掉

         <asp:TemplateField  HeaderStyle-CssClass="style6" ItemStyle-CssClass="style6" FooterStyle-CssClass="style6">

          <ItemTemplate>

          <asp:LinkButton ID="SelectButton" runat="server" CommandName="Select"></asp:LinkButton>

          </ItemTemplate>

          <FooterStyle CssClass="style6" />

          <HeaderStyle CssClass="style6" />

          <ItemStyle CssClass="style6" />

          </asp:TemplateField>

     

    2:在access数据库中,如果有关键字做字段必须用[]括起来

    3: access数据库中,如果要把日期转换成字符,用formate函数即可

       如: format(start_date, 'yyyymm') like 200806%

    4: 找不到类的名称空间

           由于类所在的名称空间与引用时的名称空间不一致,只要两者名称空间改一致即可

    5: 合并列

     Page_load 事件

    TableCell oldTc = GridView1.Rows[0].Cells[0];        for (int i = 1; i < GridView1.Rows.Count; i++)        {                                  TableCell tc = GridView1.Rows[i].Cells[0];                if (oldTc.Text == tc.Text)            {                tc.Visible = false;                if (oldTc.RowSpan == 0)                {                    oldTc.RowSpan = 1;                }                oldTc.RowSpan++;                oldTc.VerticalAlign = VerticalAlign.Middle;           

                }            else            {                oldTc = tc;            }        }

    7: javascript 获取dropdownlistbox下拉式列表的值

    empid=document.getElementById("ddl_employess").options[document.getElementById("ddl_employess").selectedIndex].value;

    8:treeviewNavgateUrl赋值时,treenodselected事件将不被触发,

      为了实现功能树的导航功能,可以把url的值保存在nodevalue值,通过在treenodselected事件写如下代码:可实现导向功能:

    Response.Write("<script>window.parent.frames['Desktop'].location.href='" + this.fun_tree.SelectedNode.Value + "'</script>");


    最新回复(0)