Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc 不显示数据_Asp.net Mvc_Oop_Collections - Fatal编程技术网

Asp.net mvc 不显示数据

Asp.net mvc 不显示数据,asp.net-mvc,oop,collections,Asp.net Mvc,Oop,Collections,谁能帮我一下吗。 public Dictionary<string,object> UserExistOrNot() { Dictionary<string, object> result = new Dictionary<string, object>(); SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["con

谁能帮我一下吗。

public Dictionary<string,object> UserExistOrNot()
    {
        Dictionary<string, object> result = new Dictionary<string, object>();
        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["conStr"].ConnectionString);
            string _userName = "user01";
            string _password = "user";
            string sqlQuery = "select * from [User] t0 inner join UserProfile t1 on t0.UserId=t1.UserId where t0.UserName='" + _userName + "' and t0.Password='" + _password+"'";
            SqlDataAdapter da = new SqlDataAdapter(sqlQuery, con);
            DataSet ds = new DataSet();
            da.Fill(ds, "usertable");
            if (ds.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    result.Add("UserId", dr["UserId"]);
                    result.Add("UserName", dr["UserName"]);
                    result.Add("Password", dr["Password"]);
                    result.Add("Email", dr["Email"]);
                    result.Add("Mobile", dr["Mobile"]);
                    result.Add("Gender", dr["Gender"]);
                    result.Add("Street1", dr["Street1"]);
                    result.Add("Street2", dr["Street2"]);
                    result.Add("Street3", dr["Street3"]);
                    result.Add("Street4", dr["Street4"]);
                    result.Add("CityId", dr["CityId"]);
                    result.Add("StateId", dr["StateId"]);
                    result.Add("Country", dr["Country"]);
                }
            }
            else
                return result;

        return result;
    }


我想显示数据而不是类型

浏览器理解纯文本、xml或html,但不理解复杂类型,因此您必须返回其中一种类型,或者使用模型字典创建一个视图,并迭代抛出键和V值以查看它。

在使用此结果的地方,显示代码,您的绑定错误输出在哪里?在视图中?@SandipPatel实际上这个UserExistornot是从我的控制器的action方法调用的方法。因此,出于测试目的,我希望在从操作调用方法之前在浏览器上显示数据method@StephenMuecke在浏览器中,您显示了大量与问题无关的代码,但忽略了视图代码和显示该代码的控制器方法的相关部分!
System.Collections.Generic.Dictionary`2[System.String,System.Object]