求简化代码.解决办法
求简化代码.
cs.后缀文件
cs.后缀文件
public partial class index : System.Web.UI.Page
{
DB db = new DB();
protected void Page_Load(object sender, EventArgs e)
{
head_index();
head_index1();
head_index2();
head_index3();
head_index4();
head_index5();
}
public void head_index()
{
string sql = "select id,navigation from navigation";
DataTable dt = db.reDt(sql);
head_one.DataSource = dt;
head_one.DataBind();
}
public void head_index1()
{
int id = string.IsNullOrEmpty(Request.QueryString["id"]) ? 0 : int.Parse(Request.QueryString["id"]);
string sql = "select id,navigation_Name from navigation_Name where navigation_id = 1";
DataTable dt = db.reDt(sql);
head_1.DataSource = dt;
head_1.DataBind();
}
public void head_index2()
{
int id = string.IsNullOrEmpty(Request.QueryString["id"]) ? 0 : int.Parse(Request.QueryString["id"]);
string sql = "select id,navigation_Name from navigation_Name where navigation_id = 2";
DataTable dt = db.reDt(sql);
head_2.DataSource = dt;
head_2.DataBind();
}
public void head_index3()
{
int id = string.IsNullOrEmpty(Request.QueryString["id"]) ? 0 : int.Parse(Request.QueryString["id"]);
string sql = "select id,navigation_Name from navigation_Name where navigation_id = 3";
DataTable dt = db.reDt(sql);
head_3.DataSource = dt;
head_3.DataBind();
}
public void head_index4()
{
int id = string.IsNullOrEmpty(Request.QueryString["id"]) ? 0 : int.Parse(Request.QueryString["id"]);
string sql = "select id,navigation_Name from navigation_Name where navigation_id = 4";
DataTable dt = db.reDt(sql);
head_4.DataSource = dt;
head_4.DataBind();
}
public void head_index5()
{
int id = string.IsNullOrEmpty(Request.QueryString["id"]) ? 0 : int.Parse(Request.QueryString["id"]);
string sql = "select id,navigation_Name from navigation_Name where navigation_id = 5";