Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted
Comments
CodeReady 12-Feb-14 0:46am    
Will you please tell me what exactly error you are getting ,or it will be better if you show that error,and be specific where you are getting error.
RiswanulZaman 12-Feb-14 1:05am    
ok i'll tell u completely... i fetching data from db and bind to grid by using json. while binding data i am facing the error which is undefined error from the script block..
I have using web method for fetching data. i have put the break point on " webmethod " and that web method i have called from script... now i am not able to get cursor on the break point.. and giving error msg like undefined error
RiswanulZaman 12-Feb-14 1:12am    
very sorry.. this is my mistake only.... i have wrongly mentioned the name of the aspx page...thats why i was getting error now only i have noticed that...
RiswanulZaman 12-Feb-14 1:06am    
ok i'll tell u completely... i fetching data from db and bind to grid by using json. while binding data i am facing the error which is undefined error from the script block..
I have using web method for fetching data. i have put the break point on " webmethod " and that web method i have called from script... now i am not able to get cursor on the break point.. and giving error msg like undefined error
CodeReady 12-Feb-14 1:26am    
thats great cheers :)

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