TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
sangeetha k
NA
207
51.3k
Help n Handling web service in Gridview 3tier architecture
Oct 26 2017 5:41 AM
#my code behind
public void ShowGrid()
{
ServiceReference1.Service1Client client = new ServiceReference1.Service1Client();
DataTable dt = client.DisplayProductDetails();
grdView1.DataSource = dt;
grdView1.DataBind();
}
# my web service coding
public class Service1 : IService1
{
BllClass bll = new BllClass();
public DataTable DisplayProductDetails()
{
return bll.DisplayProductDetails();
}
public void AddNewProduct(EntityClass en)
{
bll.AddNewProduct(en);
}
public void UpdateProductDetail(EntityClass en)
{
bll.UpdateProductDetail(en);
}
public void RemoveProduct(EntityClass en)
{
bll.RemoveProduct(en);
}
}
#webservice Iservice page coding
[ServiceContract]
public interface IService1
{
[OperationContract]
DataTable DisplayProductDetails();
[OperationContract]
void AddNewProduct(EntityClass en);
[OperationContract]
void UpdateProductDetail(EntityClass en);
[OperationContract]
void RemoveProduct(EntityClass en);
// TODO: Add your service operations here
}
// Use a data contract as illustrated in the sample below to add composite types to service operations.
//[DataContract]
//public class CompositeType
//{
// bool boolValue = true;
// string stringValue = "Hello ";
// [DataMember]
// public bool BoolValue
// {
// get { return boolValue; }
// set { boolValue = value; }
// } //I have commented it out becoz i have my entity layer seperately
// [DataMember]
// public string StringValue
// {
// get { return stringValue; }
// set { stringValue = value; }
// }
//}
#my bal
/// <returns></returns>
public DataTable DisplayProductDetails()
{
DataTable dt;
try
{
dt = new DataTable();
dt = dal.ProductDetailsDisplay();
return dt;
}
catch (Exception ex)
{
throw ex;
}
}
# Dal
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();
}
}
}
The following code doesnt how any error but the thing is the grid is not displaying ? why it is happening?
Reply
Answers (
2
)
How to login, using SP in MVC where checking user role...?
COM and multithreading