Click here to Skip to main content
15,789,698 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I try to use asp gridview for this i try webmethod and jquery to fetch data from database now when i use html gridview like this

What I have tried:

then gridview is display on page but when i use asp gridview like this

<asp:GridView ID="GridView1" runat="server" CellPadding="4" ForeColor="#333333" 
    GridLines="None" onpageindexchanging="GridView1_PageIndexChanging" 
    AutoGenerateColumns="False" AllowPaging="True"  OnRowCommand="GridView1_select"
    <AlternatingRowStyle BackColor="White" />
    <EditRowStyle BackColor="#7C6F57" />
    <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
    <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
    <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
    <RowStyle BackColor="#E3EAEB" />
    <SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
    <SortedAscendingCellStyle BackColor="#F8FAFA" />
    <SortedAscendingHeaderStyle BackColor="#246B61" />
    <SortedDescendingCellStyle BackColor="#D4DFE1" />
    <SortedDescendingHeaderStyle BackColor="#15524A" />
    <asp:BoundField DataField="ID" HeaderText="ID"/>  
    <asp:BoundField DataField="OwnerName" HeaderText="OwnerName"/> 
    <asp:BoundField DataField="RegNo" HeaderText="RegNo"/> 
                <asp:LinkButton ID="lbViewChart" Text="View Chart" CssClass="lbViewChart"  runat="server" />

but grid is not display on page ..

Jquery code

<script type="text/javascript">
$(function () {
    $('[ID*=search_data]').on('click', function () {
        var fromdate = $('[ID*=fromdate]').val();
        var todate = $('[ID*=todate]').val();
        var regiondrop = $('[ID*=regiondrop] option:selected')[0].value;
        var GridView1 = $('[ID*=GridView1]');
        var obj = {};
        obj.fromdate = fromdate;
        obj.todate = todate;
        obj.regiondrop = regiondrop;
        return false;
  function Getdataa(obj) {
                type: "POST",
                url: "WebForm1.aspx/search_data",
    data: "{'fromdate':'" + obj.fromdate + "','todate':'" + obj.todate + "','regiondrop':'" + obj.regiondrop + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                async: true,
                cache: false,
                success: function (result) {
                    var final = JSON.parse(result.d).response;
                    if (final.length > 0) {
                        for (var i = 0; i < final.length; i++) {
                            if (final[i] !== null) {
                                $("#GridView1").append("<tr><td>" +
                               final[i][0] + "</td> <td>" +
                               final[i][1] + "</td> <td>" +

                    else {
                        $("#Label4").text("No Data");
                error: function (error) {


so is this possible to use asp grid view ? ANY solution?
Updated 18-Jul-16 2:15am
F-ES Sitecore 18-Jul-16 4:35am    
A gridview is a server-side component that generates a table in the client html. It's not a client-side control that you can interact with. If you want to update the data using jquery then don't use a gridview, just use a standard html table. You won't get the server-side functionality that a gridview provides though.
super_user 18-Jul-16 5:24am    
if i use html table like this <table>
then i dont want to insert data manually i fetch data from database so what i write instead of first name and jill
F-ES Sitecore 18-Jul-16 6:05am    
Generate the html using asp:Repeater. Google " build html table with repeater" and you'll probably find examples.
super_user 18-Jul-16 6:33am    
hi.. when i add this .. <asp:Repeater ID="gridata" runat="server">
<table cellspacing="0" rules="all" border="1">



then this repeater not display on page
F-ES Sitecore 18-Jul-16 6:40am    

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