Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用详细信息视图和 sqldatasource 控件来填充它。每隔一段时间我就会收到一条错误消息,因为返回了不止一行。如果返回多行,如何在 gridview 中显示数据?
对两者进行数据绑定并将其放在 OnDataBound 事件中或代码中的任何适当位置。(显然,您需要调整对象名称的代码)
if(myDataTable.Rows.Count > 1) { myGridView.Visible = true; myDetailsView.Visible = false; } else { myGridView.Visible = false; myDetailsView.Visible = true; }