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)"));
                            }
                        }
    
                    }
                });
  • 相关阅读:
    八月二十九学习报告
    文本操作
    EL表达式
    注解开发
    逆向
    内置对象和方法
    每日日报2020.11.10 1905
    每日日报2020.11.12 1905
    每日日报2020.11.17 1905
    每日日报2020.11.20 1905
  • 原文地址:https://www.cnblogs.com/wth2010/p/3486919.html
Copyright © 2011-2022 走看看