I want to get the information from my database to a gridview. I have the following but I am unsure where and how to declare the data set as this method isn’t working:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace ConsumeDSetService
{
public partial class _Default : System.Web.UI.Page
{
public class MyDataSet
{
public static DataSet ds;
}
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
localhost.Service1 myws = new localhost.Service1();
ds = myws.GetDataSet();
GridView1.DataSource = ds;
GridView1.DataBind();
}
}
}
I’m guessing that this code doesn’t compile?
dsis a property of the class MyDataSet so you would need to reference it asMyDataSet.dsfrom the button click, which is part of the class_Default