如何在jquery中更改gridview的内容 [英] how to change the content of gridview in jquery

查看:70
本文介绍了如何在jquery中更改gridview的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的html中为表头标记三个标记,一个用于表行,最后一个用于交替行。

一些它看起来像这样



I am geeting three tag in my html one for table header , one for table row and last one for alternating row.
some what it look like this

<table id="MainContent_gridUserData" cellspacing="0" cellpadding="4" style="border-color:#CC9966;border-width:0px;font-family:Trebuchet MS;font-size:11px;width:100%;border-collapse:collapse;">
<tbody>
<tr class="User" align="left" style="color:#FFFFCC;background-color:#5BACD7;font-family:Trebuchet MS;font-size:12px;font-weight:bold;">
<tr class="RowStyle">
<tr class="AlterNateRowStyle">
<tr class="RowStyle">
<tr class="AlterNateRowStyle">
<tr class="RowStyle">





所以如何在我的jqyery中替换它





so how would i replace this in my jqyery

<table>
              <asp:GridView id="gridUserData" runat="server" BorderWidth="0px" Width="100%"

                  BorderColor="#CC9966" AllowPaging="true" PageSize="5" OnPageIndexChanging="gridUserData_PageIndexChanging"

              OnSorting="GridUserData_Sorting" CellPadding="4" AllowSorting="true" AutoGenerateColumns="False"

                            Font-Names="Trebuchet MS" Font-Size="11px"

                  RowStyle-BackColor="WhiteSmoke" AlternatingRowStyle-BackColor="lavender"

                  AlternatingRowStyle-CssClass="AlterNateRowStyle"  RowStyle-CssClass="RowStyle" PagerSettings-Mode="Numeric"

                  GridLines="None">
                            <FooterStyle BackColor="#FFFFCC" ForeColor="#330099" />
                            <%--<RowStyle BackColor="Gainsboro" ForeColor="Black" />--%>
                            <PagerStyle BackColor="#FFFFCC" ForeColor="#330099" HorizontalAlign="Right" Font-Size="Larger" />
                            <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="#663399" />
                            <HeaderStyle CssClass="User" BackColor="#5bacd7" Font-Bold="True" ForeColor="#FFFFCC" Font-Size="12px" Font-Names="Trebuchet MS" HorizontalAlign="Left"/>
                            <PagerSettings Mode="NumericFirstLast" PageButtonCount="5" FirstPageText="First" LastPageText="Last" />
                            <%-- <AlternatingRowStyle Font-Names="Trebuchet MS"/>--%>

                            <Columns>

                                <asp:TemplateField HeaderText="User Code" HeaderStyle-Width="110px" SortExpression="USRM_USER_CD"  >
                                    <ItemTemplate>
                                        <asp:Label ID="lblRepUserCode" runat="server" Text='<%#Eval("USRM_USER_CD")%>' />
                                    </ItemTemplate>

                                </asp:TemplateField>

                                <asp:TemplateField HeaderText="User Name" SortExpression="USRM_USER_NAME" HeaderStyle-Width="150px">
                                    <ItemTemplate>
                                        <asp:Label ID="lblRepUserName" runat="server" Text='<%#Eval("USRM_USER_NAME")%>' />
                                    </ItemTemplate>

                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Login IP" HeaderStyle-Width="110px">
                                    <ItemTemplate>
                                        <asp:Label ID="lblRepLoginId" runat="server" Text='<%#Eval("USRM_LAST_LOGIN_IP")%>' />
                                    </ItemTemplate>

                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Last Login Date" HeaderStyle-Width="110px">
                                    <ItemTemplate>
                                        <asp:Label ID="lblLastLoginDate" runat="server" Text='<%#Eval("USRM_LAST_LOGIN_DT","{0:dd MMM yyyy}")%>' />
                                    </ItemTemplate>

                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Status" HeaderStyle-Width="110px">
                                    <ItemTemplate>
                                        <asp:Label ID="lblStatus" runat="server" Text='<%#Eval("RECSTATUS")%>' />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="" HeaderStyle-Width="46px">
                                    <ItemTemplate>
                                         <input type="button" class="DisplayData Edit_Btn" id="<%#Eval("USRM_USER_CD")%>" Text="Edit" title="Edit" />
                                    </ItemTemplate>

                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="" HeaderStyle-Width="46px">
                                    <ItemTemplate>
                                       <input type="button" class="DisplayData Del_Btn" id="<%#Eval("USRM_USER_CD")%>" Text="Delete" title="Delete" />
                                    </ItemTemplate>

                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="" HeaderStyle-Width="46px">
                                    <ItemTemplate>
                                        <input type="button" class="Passwordchange PasswordChng_Btn" id="<%#Eval("USRM_USER_CD")%>" title="Change Password" />
                                    </ItemTemplate>

                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="" HeaderStyle-Width="46px">
                                    <ItemTemplate>
                                    <input type="button" class="ApprovedUser Approved_Btn" id="<%#Eval("USRM_USER_CD")%>" title="Approved User" />
                                    </ItemTemplate>
                                     </asp:TemplateField>
                           </Columns>
                        </asp:GridView>
          </table>










<System.Web.Services.WebMethod()> _
<ScriptMethod(ResponseFormat:=ResponseFormat.Json)> _
    Public Shared Function GetProducts() As List(Of clsUSRM)
        Dim str As String = ""
        Dim table As DataTable = clsUSRM.ListData(str)

        Dim list As New List(Of clsUSRM)()

        For Each row As DataRow In table.Rows
            Dim detail As New clsUSRM()
            detail.USRM_USER_CD = (row("USRM_USER_CD")).ToString()
            detail.USRM_USER_NAME = row("USRM_USER_NAME").ToString()
            detail.USRM_LAST_LOGIN_IP = (row("USRM_LAST_LOGIN_IP")).ToString
            detail.USRM_LAST_LOGIN_DT = (row("USRM_LAST_LOGIN_DT")).ToString
            detail.USRM_STS = (row("RECSTATUS")).ToString
            list.Add(detail)
        Next
        Return list
    End Function







function BindGridView() {
       var htmls = $("#MainContent_gridUserData").html;
       var content = '';
       $.ajax({
           type: "POST",
           url: "User_Create_Update.aspx/GetProducts",
           data: "{}",
           contentType: "application/json",
           dataType: "json",
           success: function (data) {
               for (var i = 0; i < data.d.length; i++) {



                   content += '<tr>';

                   content += '<td>' + data.d[i].USRM_USER_NAME + '</td>';
                   content += '<td>' + data.d[i].USRM_LAST_LOGIN_IP + '</td>';
                   content += '<td>' + data.d[i].USRM_LAST_LOGIN_DT + '</td>';
                   content += '<td>' + data.d[i].USRM_STS + '</td>';
                   content += '<td><input class="DisplayData Edit_Btn">  </td>';
                   content += '<td> <input class="DisplayData Del_Btn"></td>';
                   content += '<td><input class="Passwordchange PasswordChng_Btn"></td>';
                   content += '<td><input class="ApprovedUser Approved_Btn"></td>';
                   content += '</tr>';
               }
               $('#MainContent_gridUserData tbody').html(content);
           }
       })
   }

推荐答案

(\"#MainContent_gridUserData\").html;
var content = '';
("#MainContent_gridUserData").html; var content = '';


.ajax({
type: \"POST\",
url: \"User_Create_Update.aspx/GetProducts\",
data: \"{}\",
contentType: \"application/json\",
dataType: \"json\",
success: function (data) {
for (var i = 0; i < data.d.length; i++) {



content += '<tr>';

content += '<td>' + data.d[i].USRM_USER_NAME + '</td>';
content += '<td>' + data.d[i].USRM_LAST_LOGIN_IP + '</td>';
content += '<td>' + data.d[i].USRM_LAST_LOGIN_DT + '</td>';
content += '<td>' + data.d[i].USRM_STS + '</td>';
content += '<td><input class=\"DisplayData Edit_Btn\"> </td>';
content += '<td> <input class=\"DisplayData Del_Btn\"></td>';
content += '<td><input class=\"Passwordchange PasswordChng_Btn\"></td>';
content += '<td><input class=\"ApprovedUser Approved_Btn\"></td>';
content += '</tr>';
}
.ajax({ type: "POST", url: "User_Create_Update.aspx/GetProducts", data: "{}", contentType: "application/json", dataType: "json", success: function (data) { for (var i = 0; i < data.d.length; i++) { content += '<tr>'; content += '<td>' + data.d[i].USRM_USER_NAME + '</td>'; content += '<td>' + data.d[i].USRM_LAST_LOGIN_IP + '</td>'; content += '<td>' + data.d[i].USRM_LAST_LOGIN_DT + '</td>'; content += '<td>' + data.d[i].USRM_STS + '</td>'; content += '<td><input class="DisplayData Edit_Btn"> </td>'; content += '<td> <input class="DisplayData Del_Btn"></td>'; content += '<td><input class="Passwordchange PasswordChng_Btn"></td>'; content += '<td><input class="ApprovedUser Approved_Btn"></td>'; content += '</tr>'; }


('#MainContent_gridUserData tbody').html(content);
}
})
}
('#MainContent_gridUserData tbody').html(content); } }) }


这篇关于如何在jquery中更改gridview的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆