i am facing error in this coding...
Plz Help Me..........
<script type="text/javascript">
$(function () {
$.ajax({
type: "POST",
url: "BindGridViewusingJQuery.aspx/GetUserInfoData",
data: '{}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
failure: function (response) {
alert("Failure : " + response.d);
},
error: function (response) {
alert("Error : " + response.d);
}
});
});
function OnSuccess(response) {
var xmlDoc = $.parseXML(response.d);
var xml = $(xmlDoc);
var users = xml.find("Table");
//create a new row from the last row of gridview
var row = $("[id*=grid] tr:last-child").clone(true);
//remove the lst row created by binding the dummy row from code behind on page load
$("[id*=grid] tr").not($("[id*=grid] tr:first-child")).remove();
var count = 1;
$.each(users, function () {
var users = $(this);
$("td", row).eq(1).html($(this).find("Name").text());
$("td", row).eq(2).html($(this).find("Subject").text());
$("td", row).eq(3).html($(this).find("Description").text());
$("td", row).eq(0).html($(this).find("Id").text());
$("[id*=grid]").append(row);
//define the background stryle of newly created row
if (count == 1 || (count % 2 != 0)) {
$(row).css("background-color", "#ffffff");
}
else {
$(row).css("background-color", "#D2CDCD");
}
count = count + 1;
row = $("[id*=grid] tr:last-child").clone(true);
});
}
</script>
<asp:GridView ID="grid" runat="server" AutoGenerateColumns="false" DataKeyNames="Id"
DataMember="Id">
<columns> <asp:BoundField DataField="Name" HeaderText="Name" />
<asp:BoundField DataField="Subject" HeaderText="Subject" />
<asp:BoundField DataField="Description" HeaderText="Description" />
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
Call BindDummyRow()
End If
End Sub
Private Sub BindDummyRow()
Try
Dim mTable As New DataTable
mTable.Columns.Add("Name")
mTable.Columns.Add("SubJect")
mTable.Columns.Add("Description")
mTable.Columns.Add("Id")
mTable.Rows.Add()
grid.DataSource = mTable
grid.DataBind()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
<webmethod()> _
Public Shared Function GetUserInfoData() As String
Dim mString As String = ConfigurationManager.ConnectionStrings("ApplicationServices").ConnectionString
Dim ds As New DataSet
Using con As New SqlConnection(mString)
con.Open()
Using cmd As SqlCommand = con.CreateCommand
cmd.CommandType = Data.CommandType.Text
cmd.CommandText = " SELECT * FROM [dbo].[TEMP_User]"
Dim da As New SqlDataAdapter(cmd)
da.Fill(ds, "Table")
Return ds.GetXml()
con.Close()
End Using
End Using
End Function