我有一个像这样的表,在后面的代码中,我必须在标签中显示 tempname 并在下拉列表中显示 rundate 我必须在下拉列表中显示最近 10 个 rundates 而没有重复的名称DDL 中的运行日期。我怎样才能做到这一点?我需要一个相同的存储过程。
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
DataTable dt = new DataTable();
dt = Common.rundate();
DropDownList ddl = e.Row.FindControl("DropDownList1") as DropDownList;
ddl.DataTextField = "RunDate";
ddl.DataValueField = "TempID";
ddl.DataSource = dt;
ddl.DataBind();
}
}
public static DataTable rundate()
{
DBAccess objDBAccess = new DBAccess();
DataTable dt = new DataTable();
try
{
objDBAccess.AddParameter("@tempname", SqlDbType.VarChar);
objDBAccess.AddParameter("@tempid", SqlDbType.Int);
objDBAccess.AddParameter("@rundate", SqlDbType.DateTime);
dt = objDBAccess.ExecuteDataTable("display_rundates");
return dt;
}
catch
{
return null;
}
}