Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

XML
<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">


so how would i replace this in my jqyery

XML
<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>



XML
<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


XML
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);
           }
       })
   }
Posted
Updated 3-Mar-13 8:12am
v2
Comments
agnesn88 13-Mar-13 2:55am    
--->read http://jquerygridview.com/

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900