多表查询出来的数据绑定Repeater
如果我有三个表,表的结构都一样,只是里面的数据不一样!有放手机数据的,有放相机数据的,有电脑数据的,通过怎么查询可以把三表的数据,绑定Repeater上!需要补充说下!如...
如果我有三个表,表的结构都一样,只是里面的数据不一样!有放手机数据的,有放相机数据的,有电脑数据的,通过怎么查询可以把三表的数据,绑定Repeater上!
需要补充说下!如果要用存储过程的话请写清楚! 展开
需要补充说下!如果要用存储过程的话请写清楚! 展开
2013-05-30
展开全部
public class Class1
{
static string ConnStr = "server=.;uid=sa;pwd=sa;database=bbs";
public static DataTable GetTable()
{
using (SqlConnection conn = new SqlConnection(ConnStr))
{
conn.Open();
SqlCommand cmd = new SqlCommand("select * from t1;select * from t2;select * from t3", conn);
SqlDataReader dr = cmd.ExecuteReader();
DataTable dt = new DataTable();
dt.Columns.Add("aid", typeof(System.String));
dt.Columns.Add("aname", typeof(System.String));
do
{
while (dr.Read())
{
DataRow dtr = dt.NewRow();
dtr["aid"] = dr["aid"];
dtr["aname"] = dr["aname"];
dt.Rows.Add(dtr);
}
}
while (dr.NextResult());
return dt;
}
}
}
{
static string ConnStr = "server=.;uid=sa;pwd=sa;database=bbs";
public static DataTable GetTable()
{
using (SqlConnection conn = new SqlConnection(ConnStr))
{
conn.Open();
SqlCommand cmd = new SqlCommand("select * from t1;select * from t2;select * from t3", conn);
SqlDataReader dr = cmd.ExecuteReader();
DataTable dt = new DataTable();
dt.Columns.Add("aid", typeof(System.String));
dt.Columns.Add("aname", typeof(System.String));
do
{
while (dr.Read())
{
DataRow dtr = dt.NewRow();
dtr["aid"] = dr["aid"];
dtr["aname"] = dr["aname"];
dt.Rows.Add(dtr);
}
}
while (dr.NextResult());
return dt;
}
}
}
2013-05-30
展开全部
protected void btnCrstal_Click(object sender, EventArgs e)
{
repbindnew();
}
protected void repbindnew()
{
Repeater1.DataSource = Getranknew().DefaultView;
Repeater1.DataBind();
}
protected DataTable Getranknew()
{
DateTime date = DateTime.Parse(ddlweek.SelectedValue);
DataSet ds = dbreport.MediaRankingnew(productid, this.ddlmediasort.SelectedValue, date.AddDays(-6).ToString(), date.ToString());
DataTable dtnowe = ds.Tables[1];
DataTable dtolde = ds.Tables[0];
dtolde = dtolde.DefaultView.ToTable();
dtnowe = dtnowe.DefaultView.ToTable();
return dtnowe;
}
{
repbindnew();
}
protected void repbindnew()
{
Repeater1.DataSource = Getranknew().DefaultView;
Repeater1.DataBind();
}
protected DataTable Getranknew()
{
DateTime date = DateTime.Parse(ddlweek.SelectedValue);
DataSet ds = dbreport.MediaRankingnew(productid, this.ddlmediasort.SelectedValue, date.AddDays(-6).ToString(), date.ToString());
DataTable dtnowe = ds.Tables[1];
DataTable dtolde = ds.Tables[0];
dtolde = dtolde.DefaultView.ToTable();
dtnowe = dtnowe.DefaultView.ToTable();
return dtnowe;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询