【发布时间】:2017-01-10 16:14:30
【问题描述】:
从存储在我的数据库中的数据中对我的 gridview 进行数据绑定时,我看到一个小方块出现,而不是预期的 gridview 结果。
我正在使用的代码:
try
{
DataTable dsDetalle = new DataTable("Data");
using (MySqlCommand commandSql = cn.CreateCommand())
{
commandSql.CommandType = CommandType.Text;
commandSql.CommandText = "select * from detalle where iddetalle=@iddetalle and idlocal=@idlocal";
commandSql.Parameters.AddWithValue("@iddetalle", "txt_boleta.Text");
commandSql.Parameters.AddWithValue("@idlocal", "txtlocal.Text");
MySqlDataAdapter sqlAdapter = new MySqlDataAdapter(commandSql);
sqlAdapter.Fill(dsDetalle);
}
GridView1.DataSource = dsDetalle;
GridView1.DataBind();
}
catch (Exception ex)
{
lblerror.Text = ex.ToString();
}
【问题讨论】:
-
调试时你尝试过什么?例如,我要做的第一件事是检查数据表以确保按预期存储内容,如果没有按照之前的代码进行操作。
-
感谢更正,是的,我检查了数据并且查询正常
-
你能从aspx页面显示GridView代码吗?也许它在那里......
-
-
感谢您的帮助,我发现了@the Muffin Man 的错误,原因是我在查询中遇到了问题,感谢您的帮助:D