Your method signature does not return a value, hence you cannot retrieve a string.
The method signature is the below part...
public void GetDaywiseData(string dep)
The keyword
void means that a value will not be returned - in VB6 this is known as a Sub.
To return a value you would change your method signature to identify the type of return value - the below returns a string value;
public string GetDaywiseData(string dep)
Based on the code above, the easiest solution is as follows;
[WebMethod]
public DataTable GetDaywiseData(string dep)
{
try
{
DataTable dtReturn;
string cs = ConfigurationManager.ConnectionStrings["sa"].ConnectionString;
using (SqlConnection con = new SqlConnection(cs))
{
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandType = System.Data.CommandType.Text;
cmd.CommandText = " select a.doctor_nm AS DOCTORNAME,[dbo].[fn_docdays](doc_id) as DAYS,b.dept_nm AS DEPARTMENT from (select * from doctor_master) as a inner join (select * from deptmaster)as b on a.dept_cd = b.dept_cd where b.dept_nm = '"+dep+"'";
con.Open();
SqlDataAdapter adap = new SqlDataAdapter(cmd);
adap.Fill(dtReturn);
}
return dtReturn;
}
The datatable will be returned from the WebService, which is then set as the datasource of your Grid
Kind Regards