sangeetha k

sangeetha k

  • NA
  • 207
  • 49.3k

Unable to return the table

Oct 27 2017 6:45 AM
The thing is I am displaying a gridview in the webpage but everything is happening but after the return statement in svc file of the grid the control is not returning the table to code behind page it simply shows the empty page  
 
# my dll 
public DataTable ProductDetailsDisplay()
{
DataTable dt = new DataTable();
SqlCommandBuilder cb;
SqlDataAdapter adp;
SqlConnection conn = new SqlConnection(constring);
try
{
conn.Open();
SqlCommand cmd = new SqlCommand("spDisplayProductDetails", conn);
cmd.CommandType = CommandType.StoredProcedure;
adp = new SqlDataAdapter(cmd);
cb = new SqlCommandBuilder(adp);
adp.Fill(dt);
return dt;
}
catch (SqlException)
{
throw new Exception("");
}
catch (FormatException)
{
throw new Exception("Input Field supplied was not there in the correct Format");
}
catch (NullReferenceException)
{
throw new Exception("");
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
finally
{
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
}
}
 
 
# My Bal 
///
public DataTable DisplayProductDetails()
{
DataTable dt;
try
{
dt = new DataTable();
dt = dal.ProductDetailsDisplay();
return dt;
}
catch (Exception ex)
{
throw ex;
}
}
# my webservice interface 
public class Service1 : IService1
{
BllClass bll = new BllClass();
public ProductDetail DisplayProductDetails()
{
ProductDetail pd = new ProductDetail();
pd.ProductInfo = bll.DisplayProductDetails();
return pd;
}

#interface
[DataContract]
public class ProductDetail
{
[DataMember]
public DataTable ProductInfo
{
get;
set;
}
 #code behind
 
public void ShowGrid()
{
ServiceReference1.ProductDetail pd = new ServiceReference1.ProductDetail();
ServiceReference1.Service1Client Myservice = new ServiceReference1.Service1Client();
DataTable dt = new DataTable();
pd= Myservice.DisplayProductDetails();
dt=pd.ProductInfo;
grdView1.DataSource = dt;
grdView1.DataBind();
}
 

Answers (1)