本文介绍了数据源是无效类型。它必须是ilistource,ienumerable或idatasource。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,我尝试了大部分的事情,但是如果你们都可以提供帮助就没有得到完美的解决方案
我尝试了什么:
int id = Convert.ToInt32(Session [UserID]);
string connection = ConfigurationManager.AppSettings [Connection]。ToString();
使用(SqlConnection con = new SqlConnection(connection))
{
con.Open();
using(SqlCommand cmd = new SqlCommand(Score_Page,con))
{
cmd.Parameters.AddWithValue(@ ID,id);
DataTable cop = new DataTable();
SqlDataAdapter sad = new SqlDataAdapter(cmd);
cmd.CommandType = CommandType.StoredProcedure;
sad.Fill(警察);
int sco =(int)cop.Rows [0] [0];
int scr = percentage();
int sro =(int)((sco * 100)/ scr);
//int.TryParse(cop.Rows [0] [0] .ToString(),out sro);
con.Close();
GridView1.DataSource = sro;
GridView1.DataBind();
解决方案
Hello everyone, I am tried most of the thing but didn't got the perfect solution if you can all can help
What I have tried:
int id = Convert.ToInt32(Session["UserID"]); string connection = ConfigurationManager.AppSettings["Connection"].ToString(); using (SqlConnection con = new SqlConnection(connection)) { con.Open(); using (SqlCommand cmd = new SqlCommand("Score_Page", con)) { cmd.Parameters.AddWithValue("@ID", id); DataTable cop = new DataTable(); SqlDataAdapter sad = new SqlDataAdapter(cmd); cmd.CommandType = CommandType.StoredProcedure; sad.Fill(cop); int sco = (int)cop.Rows[0][0]; int scr = percentage(); int sro = (int)((sco * 100) / scr); //int.TryParse(cop.Rows[0][0].ToString(), out sro); con.Close(); GridView1.DataSource = sro; GridView1.DataBind();
解决方案
这篇关于数据源是无效类型。它必须是ilistource,ienumerable或idatasource。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!