简单常用的方法
/// <summary>
/// 绑定DropDownList控件
/// </summary>
/// <param name="ds"></param>
/// <param name="drp"></param>
/// <param name="TextField"></param>
/// <param name="ValueField"></param>
public void BinControlsDropDownList(DataSet ds,DropDownList drp, string TextField, string ValueField,string Values)
{
drp.DataSource = ds;
drp.DataTextField = TextField;
drp.DataValueField = ValueField;
drp.DataBind();
if (Values != "")
drp.SelectedValue = Values;
}
/// <summary>
/// 获得当前周期 DateTime.Now.DayOfWeek.ToString() 可以得到当前星期 但可惜是英文的所以需要转换
/// </summary>
/// <returns></returns>
public string CaculateWeekDay(string week)
{
string weekstr = "";
switch (week)
{
case "Monday": weekstr = "星期一"; break;
case "Tuesday": weekstr = "星期二"; break;
case "Wednesday": weekstr = "星期三"; break;
case "Thursday": weekstr = "星期四"; break;
case "Friday": weekstr = "星期五"; break;
case "Saturday": weekstr = "星期六"; break;
case "Sunday": weekstr = "星期日"; break;
}
return weekstr;
}
/// 绑定DropDownList控件
/// </summary>
/// <param name="ds"></param>
/// <param name="drp"></param>
/// <param name="TextField"></param>
/// <param name="ValueField"></param>
public void BinControlsDropDownList(DataSet ds,DropDownList drp, string TextField, string ValueField,string Values)
{
drp.DataSource = ds;
drp.DataTextField = TextField;
drp.DataValueField = ValueField;
drp.DataBind();
if (Values != "")
drp.SelectedValue = Values;
}
/// <summary>
/// 获得当前周期 DateTime.Now.DayOfWeek.ToString() 可以得到当前星期 但可惜是英文的所以需要转换
/// </summary>
/// <returns></returns>
public string CaculateWeekDay(string week)
{
string weekstr = "";
switch (week)
{
case "Monday": weekstr = "星期一"; break;
case "Tuesday": weekstr = "星期二"; break;
case "Wednesday": weekstr = "星期三"; break;
case "Thursday": weekstr = "星期四"; break;
case "Friday": weekstr = "星期五"; break;
case "Saturday": weekstr = "星期六"; break;
case "Sunday": weekstr = "星期日"; break;
}
return weekstr;
}