Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
Hi all, I need to create a web service to pass the dataset to javascript function. I don't have that much idea in webservice.I wish to know the step by step process. Can anyone help to solve this out.
Thanks in advance.
Posted 26-Jun-12 19:32pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Comments at 27-Jun-12 4:24am
Thank you Vani Kulkarni.
Vani Kulkarni at 27-Jun-12 5:01am
Welcome arun! at 27-Jun-12 5:26am
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Data" %>
<script runat="server">
public static System.Data.DataTable MyMethod(int value)
return GetDataSet(value);
public static System.Data.DataTable GetDataSet(int value)
DataTable dt = new DataTable("Author");
DataRow dr;
dt.Columns.Add(new DataColumn("Id", typeof(Int32)));
dt.Columns.Add(new DataColumn("Author", typeof(string)));
for (int i = 0; i <= 10; i++)
dr = dt.NewRow();
dr[0] = i;
dr[1] = "Author" + i.ToString();
for (int i = 20; i <= 40; i++)
dr = dt.NewRow();
dr[0] = i;
dr[1] = "Author" + i.ToString();

DataView dv = new DataView(dt);
dv.RowFilter = "Id='" + value + "'";

return dv.Table;

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="">
<head id="Head1" runat="server">
<title>Untitled Page</title>
<script language="javascript" type="text/javascript">
function CallMyWebService()
function OnRequestComplete(result)
var str="";
for(var i = 0; i < result.rows.length; i++)

str+=result.rows[i].Author +"<br>";

<form id="form1" runat="server">
<asp:ScriptManager ID="scriptManger1" runat="server"

<asp:ServiceReference Path="~/WebService.asmx" />

<div id="result">
<input type="button" önclick="CallMyWebService();" id="myButton"
value="Call MyWebService" />
if you tried, you likely received some sort of circular reference serialization error to take advantage of this, you will need to add the following to your web.config:





I use the same code. But it is not working. Can u check it Vani.

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 505
1 OriginalGriff 248
2 ChintanShukla 185
3 Richard Deeming 175
4 Bhavik_Patel 170
0 Sergey Alexandrovich Kryukov 8,688
1 OriginalGriff 7,237
2 CPallini 2,598
3 Richard MacCutchan 2,080
4 Abhinav S 1,888

Advertise | Privacy | Mobile
Web04 | 2.8.140827.1 | Last Updated 27 Jun 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100