u013984302
星辰痕泪
2015-09-23 13:59

求c# mvc <select>.value正确获取方案!!!!好急!!!!!

  • select
  • mvc

view中 表单代码<% using (Html.BeginForm("DateSearch", "home"))
{%>

-
-

&nbsp &nbsp &nbsp 数据名

陆上温度
陆上压力

查询
<%}%>

    controller中   
          public ActionResult DateSearch()
    {
        sqlconnection sc = new sqlconnection();
        string datename = Request.Form["dt"] ;
        var datestring = sc.query(datename);          
        return View(datestring);
    }
            aspx.cs中  控制器中query函数代码
             public string[] query(string datename)
    {
        connect();
        string[] querydata=null;
        command = new SqlCommand("select " +datename+" from meas_group01", connection);
        SqlDataReader myReader=null;
        myReader = command.ExecuteReader();
        while(myReader.Read()&&myReader!=null)
        {
        for (int i = 0; i < myReader.FieldCount; i++)
        {
             querydata[i] = myReader[i].ToString();

        }
        }myReader.Close();
        close();
        return querydata;
    }
            显示错误是关键字 'from' 附近有语法错误 
            我判断是select的value值取得为null   求正确解决方案!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

3条回答

为你推荐