The code below refers: How can I display the result in gridview at the consumer site.
public class dclinic
{
public string ddays { get; set; }
public string dperiod { get; set; }
}
[WebMethod]
public List<dclinic> clinicPeriod(string clinic)
{
string sq = "select Days,Period from clinicperiod where clinic = @clinic";
gap.Open();
SqlCommand cq = new SqlCommand(sq, gap);
cq.Parameters.AddWithValue("@clinic", clinic);
SqlDataReader reader = cq.ExecuteReader();
DataTable dt = new DataTable();
dt.Load(reader);
gap.Close();
List<dclinic> rlist = new List<dclinic>();
for (int i = 0; i < dt.Rows.Count; i++)
{
dclinic dcc = new dclinic();
dcc.ddays = dt.Rows[i]["days"].ToString();
dcc.dperiod = dt.Rows[i]["period"].ToString();
rlist.Add(dcc);
}
return rlist;
}