查询两个表绑定到一个GRIDVIEW中 动太向行中加鏈接
DataSet ds2 = new DataSet();
DataTable dt2 = ds2.Tables.Add("jiehuodong");
dt2.Columns.Add("SN", typeof(string));
dt2.Columns.Add("zhuti", typeof(string));
dt2.Columns.Add("xiangguanxiang", typeof(string));
dt2.Columns.Add("gongzhuo", typeof(string));
dt2.Columns.Add("daoqiriqi", typeof(string));
dt2.Columns.Add("zhuangtai", typeof(string));
dt2.Columns.Add("youxiansxu", typeof(string));
dt2.Columns.Add("zhpaiduixiang", typeof(string));
string sql31 = "select SN,atitle,aitem,1 as gz,aendtime,astate,apro,assign,rsn from CRM_add_work where convert(nvarchar,aendtime,121)<getdate() and RSN='" + SN + "'";
DataSet ds31 = MySqlBase.GetVarsAsDataSet(sql31);
object[] vars3 = new object[8];
object[] vars4 = new object[8];
for (int i = 0; i < ds31.Tables[0].Rows.Count; i++)
{
//if (Convert.ToDateTime(ds11.Tables[0].Rows[i].ItemArray[4]) > DateTime.Now)
//{
vars3[0] = ds31.Tables[0].Rows[i].ItemArray[0].ToString();
vars3[1] = ds31.Tables[0].Rows[i].ItemArray[1].ToString();
vars3[2] = ds31.Tables[0].Rows[i].ItemArray[2].ToString();
vars3[3] = ds31.Tables[0].Rows[i].ItemArray[3].ToString();
vars3[4] = ds31.Tables[0].Rows[i].ItemArray[4].ToString();
vars3[5] = ds31.Tables[0].Rows[i].ItemArray[5].ToString();
vars3[6] = ds31.Tables[0].Rows[i].ItemArray[6].ToString();
vars3[7] = ds31.Tables[0].Rows[i].ItemArray[7].ToString();
dt2.Rows.Add(vars3);
//}
}
string sql22 = "select SN,ctitle,Critem,0 as sj,cend,null,null,Cassign,RSN from CRM_add_case where convert(nvarchar,cend,121)<getdate() and RSN='" + SN + "'";
DataSet ds22 = MySqlBase.GetVarsAsDataSet(sql22);
for (int j = 0; j < ds22.Tables[0].Rows.Count; j++)
{
//if (Convert.ToDateTime(ds12.Tables[0].Rows[j].ItemArray[4]) > DateTime.Now)
//{
vars4[0] = ds22.Tables[0].Rows[j].ItemArray[0].ToString();
vars4[1] = ds22.Tables[0].Rows[j].ItemArray[1].ToString();
vars4[2] = ds22.Tables[0].Rows[j].ItemArray[2].ToString();
vars4[3] = ds22.Tables[0].Rows[j].ItemArray[3].ToString();
vars4[4] = ds22.Tables[0].Rows[j].ItemArray[4].ToString();
vars4[5] = ds22.Tables[0].Rows[j].ItemArray[5].ToString();
vars4[6] = ds22.Tables[0].Rows[j].ItemArray[6].ToString();
vars4[7] = ds22.Tables[0].Rows[j].ItemArray[7].ToString();
dt2.Rows.Add(vars4);
//}
}
this.GridView1.DataSource = ds2.Tables["jiehuodong"];
this.GridView1.DataBind();
for (int t = 0; t <= this.GridView1.Rows.Count - 1; t++)
{
//DropDownList ddl = (DropDownList)this.GV_Config.Rows[t].Cells[5].FindControl("DropDownList1");
//ddl.Items.Add(new ListItem((ds.Tables[0]).Rows[i].ItemArray[5].ToString(), (ds.Tables[0]).Rows[i].ItemArray[5].ToString()));
string t1 = (ds2.Tables[0]).Rows[t].ItemArray[3].ToString();
if (t1 == "1")
{
this.GridView1.Rows[t].Cells[3].Text = "是";
this.GridView1.Rows[t].Cells[1].Text = "<a href='../CRM_Add_Work.aspx?sn=" + (ds2.Tables[0]).Rows[t].ItemArray[0].ToString() + "' onclick=\"return rForm(this, 700, 650)\" class=\"highslide\">" + (ds2.Tables[0]).Rows[t].ItemArray[1].ToString() + "</a>";
}
if (t1 == "0")
{
this.GridView1.Rows[t].Cells[3].Text = "否";
this.GridView1.Rows[t].Cells[1].Text = "<a href='../CRM_add_case_edit.aspx?SN=" + (ds2.Tables[0]).Rows[t].ItemArray[0].ToString() + "' onclick=\"return rForm(this, 700, 650)\" class=\"highslide\">" + (ds2.Tables[0]).Rows[t].ItemArray[1].ToString() + "</a>";
}
//ddl.Enablesd = false;
}