当前位置: 代码迷 >> C# >> cs后台文件如何调用其中的一段代码
  详细解决方案

cs后台文件如何调用其中的一段代码

热度:18   发布时间:2016-05-05 03:37:57.0
cs后台文件怎么调用其中的一段代码
后台文件有这么一段代码,是用于当DropDownList1选择选项的时候GridView1动态绑定数据,现在我需要在一个button时间中调用中用到下面一样的代码,那我要怎么引用这个代码,语法要怎么写,求告知谢谢。

    protected void Select_Change(object sender, EventArgs e)
    {
            int id = Convert.ToInt32(this.DropDownList1.SelectedValue);
            if(id==1)
            {
              string id1 = "select * from product";
              DB.bindGridView(id1, GridView1);
            }
            else
            {
              if(id==13)
              {
                  string id1 = "select * from product where classid in (14,15,16,18,19,21)";
                  DB.bindGridView(id1, GridView1);
              }
              else
              {
                  if(id==24)
                  {
                     string id1 = "select * from product where classid in (25)";
                     DB.bindGridView(id1, GridView1);

                  }
                  else
                  {
                     string id1 = "select * from product where classid = " + id + "";
                     DB.bindGridView(id1, GridView1);
                  }
              }
            }
     }

------解决思路----------------------
button的click事件方法里面调用
Select_Change(null,null)

------解决思路----------------------
 在button 事件里直接这样写     Select_Change(null,null)
  相关解决方案