动态给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='width: 60px;' align='center'>  "
                            + data[i].UserId +
                            "</td><td style='width: 100px;' align='center'>"
                                                    + data[i].UserName +
                                                    "</td><td style='width: 80px;' align='center'>"
                                                    + data[i].Money
                                                    + "</td><td style='width: 80px;' align='center'>" +
                                                   data[i].PayBank
                                                    + "</td><td style='width: 80px;' align='center'>" +
                                                    data[i].PayName
                                                    + "</td><td style='width: 150px;' align='center'>"
                                                     + data[i].PayAccount + " </td><td>"
                                                      + data[i].Msg + " </td><td style='width: 150px;' align='center'> "
                                                    + getNowFormatDate(data[i].STime)
                                                      + " </td><td style='width: 80px;' align='center'><font color='red'>未处理</font></td><td style='width: 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)"));
                        }
                    }

                }
            });

 

转载于:https://www.cnblogs.com/wth2010/p/3486919.html

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值