zoukankan      html  css  js  c++  java
  • 动态给gridview添加一行

            //public void AddRowsToGridView()
            //{
            //    int num = GridView1.Rows.Count;
            //    int RowNum = GridView1.Rows.Count;
            //    //for (int i = 0; i < num; i++)
            //    //{
            //    //    string str = GridView1.Rows[i].Cells[9].Text;
            //    //    if (GridView1.Rows[i].Cells[9].Text == "未处理")
            //    //    {
            //    //        RowNum++;
            //    //    }
            //    //}
    
            //    int sumRow = DBHelper.GetScalar("select count(Id) from N_UserGetCash where State=0");
            //    int updateRow = sumRow - RowNum;
            //    if (updateRow > 0)
            //    {
            //        DataTable dt = DBHelper.GetDataSet(" select  N_UserGetCash.UserId,N_User.UserName,N_UserGetCash.Money,N_User.PayBank,N_User.PayName,N_User.PayAccount,N_UserGetCash.Msg,N_UserGetCash.STime,N_UserGetCash.State,N_UserGetCash.Id from N_UserGetCash,n_user where N_UserGetCash.State=0 and N_UserGetCash.UserId=n_user.Id order by STime desc");
            //        for (int i = 0; i < dt.Rows.Count; i++)
            //        {
            //            GridViewRow row = new GridViewRow(0, 0, DataControlRowType.Separator, DataControlRowState.Normal);
            //            for (int j = 0; j < dt.Columns.Count; j++)
            //            {
            //                TableCell cell = new TableCell();
            //                if (j == 8)
            //                {
            //                    cell.Text = "未处理";
            //                }
            //                else if (j == 9)
            //                {
            //                    cell.Text = " <a href='User_GetCash_Ok.aspx?Id=" + dt.Rows[i][j].ToString() + "'>确认放款</a> <br /><a href='javascript:User_GetCash_No.aspx?Id=" + dt.Rows[i][j].ToString() + "'>拒绝放款</a>";
            //                }
            //                else
            //                {
            //                    cell.Text = dt.Rows[i][j].ToString();
            //                }
            //                row.Cells.Add(cell);
            //            }
            //            row.Visible = true;
            //            GridView1.Controls[0].Controls.AddAt(-1, row);
            //        }
            //    }
            //}
    

      js 代码操作

     function AddRowsToGridView() {
                var table = document.getElementById('GridView1');
                var RowCount = table.rows.length;
                $.ajax({
                    url: "asyn/AddRowsToGridView.ashx",
                    data: { "RowCount": RowCount },
                    type: "post",
                    success: function (msg) {
                        if (msg != "no") {
                            $("#GridView1 tbody tr").text("").find(":not(:first)").remove();
                            var data = eval("(" + msg + ")");
                            for (var i = 0; i < data.length; i++) {
                                $("<tr> <td style=' 60px;' align='center'>  "
                                + data[i].UserId +
                                "</td><td style=' 100px;' align='center'>"
                                                        + data[i].UserName +
                                                        "</td><td style=' 80px;' align='center'>"
                                                        + data[i].Money
                                                        + "</td><td style=' 80px;' align='center'>" +
                                                       data[i].PayBank
                                                        + "</td><td style=' 80px;' align='center'>" +
                                                        data[i].PayName
                                                        + "</td><td style=' 150px;' align='center'>"
                                                         + data[i].PayAccount + " </td><td>"
                                                          + data[i].Msg + " </td><td style=' 150px;' align='center'> "
                                                        + getNowFormatDate(data[i].STime)
                                                          + " </td><td style=' 80px;' align='center'><font color='red'>未处理</font></td><td style=' 80px;' align='center'> <a href='User_GetCash_Ok.aspx?Id= " + data[i].UserId + "'>确认放款</a> <br><a href='User_GetCash_No.aspx?Id= " + data[i].UserId + "'>拒绝放款</a></td></tr>").insertBefore($("#GridView1 tbody tr:eq(1)"));
                            }
                        }
    
                    }
                });
  • 相关阅读:
    c# in deep 之LINQ简介(1)
    今天开通博客
    bzoj 4009 接水果 整体二分
    区间求mex的几种方法
    充分性,必要性,充分条件,必要条件的区别
    表达式求值(noip2015等价表达式)
    selenium-模拟鼠标
    selenium学习-ActionChains方法列表
    高手指导中手的书籍
    新生
  • 原文地址:https://www.cnblogs.com/wth2010/p/3486919.html
Copyright © 2011-2022 走看看