Riddhi Valecha

Riddhi Valecha

  • 444
  • 3.3k
  • 412.8k

Bind GridView From WCF Service Datatable

Sep 27 2017 10:27 AM
Dear all,

I have made a WCF Project.

In the interface -

[OperationContract]
string GetConnectionString()
[OperationContract]
Boolean CheckIfConnectionIsOpen()
[OperationContract]
Datatable GetUsersList

In Service Class -
public string GetConnectionString()
{
return ConfigurationManager.ConnectionString["conn"].ToString();
}
public Boolean CheckIfConnectionIsOpen()
{
con.ConnectionString = GetConnectionString();
con.Open();
}
public datatable GetUsersList()
{
Datatable dt = new datatable;
cmd = new SQLCommand();
cmd.Text= "SP_LOADUSERS";
adp = new SQLDataadapter();
adp.fill(dt);
return dt;
}
----------
Now I added a new project -ASP.NET Empty Project
I added Service Reference
Code -
Service1.client client = new Service1.client();
Datatable tt = new Datatable();
tt = client.GetUsersList();
grddata.datasource =tt;
grddata.Databind();
---------
When I debug the code - the break point runs only till the method - client.GetUsersList().
The two line - grddata.datasource =tt; and grddata.Databind(); - are not getting executed.
----------

Answers (2)