“DataList1”上同时定义了 DataSource 和 DataSourceID。请移除一个定义。
请问这个怎么解决啊~?~~??要怎么移除一个?~?~?~在哪里移除啊···~~~~publicpartialclassmain:System.Web.UI.Page{pr...
请问这个怎么解决啊~?~~??要怎么移除一个?~?~?~在哪里移除啊···~~~~
public partial class main : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
this.databindlist();
}
}
public void databindlist()
{
SqlConnection con = DB.createcon();
con.Open();
SqlDataAdapter sda = new SqlDataAdapter();
sda.SelectCommand = new SqlCommand("select * from guest",con);
DataSet ds=new DataSet();
sda.Fill(ds, "guest");
this.DataList1.DataSource = ds.Tables["guest"].DefaultView;
this.DataList1.DataBind();
}
protected void DataList1_SelectedIndexChanged(object sender, EventArgs e)
{
}
} 展开
public partial class main : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
this.databindlist();
}
}
public void databindlist()
{
SqlConnection con = DB.createcon();
con.Open();
SqlDataAdapter sda = new SqlDataAdapter();
sda.SelectCommand = new SqlCommand("select * from guest",con);
DataSet ds=new DataSet();
sda.Fill(ds, "guest");
this.DataList1.DataSource = ds.Tables["guest"].DefaultView;
this.DataList1.DataBind();
}
protected void DataList1_SelectedIndexChanged(object sender, EventArgs e)
{
}
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询