我添加一個GridView &,然後從SQL Server數據庫中顯示數據。問題在於GridView不顯示在瀏覽器中,有或沒有數據。ASP.NET中的GridView不顯示有或沒有數據
這裏是我的代碼:
<asp:GridView ID="GridAllStore" runat="server" AutoGenerateColumns="False" Width="100%" ViewStateMode="Enabled">
public partial class AdminPanel : System.Web.UI.Page
{
storelocatorDataSetTableAdapters.storedbTableAdapter tastore = new storelocatorDataSetTableAdapters.storedbTableAdapter();
storelocatorDataSetTableAdapters.View_1TableAdapter taview = new storelocatorDataSetTableAdapters.View_1TableAdapter();
List<storelocatorDataSet.storedbRow> lststore = new List<storelocatorDataSet.storedbRow>();
List<storelocatorDataSet.View_1Row> lstview = new List<storelocatorDataSet.View_1Row>();
protected void Page_Load(object sender, EventArgs e)
{
lstview = taview.GetData().ToList();
GridAllStore.DataSource = lstview;
}
}
我想你忘了打電話'GridAllStore.DataBind()' – MilkyWayJoe 2012-04-23 21:48:53
你要麼必須的AutoGenerateColumns設置爲請將列提供爲要顯示的Bound-或TemplateField。您必須以任何方式進行DataBind。 – 2012-04-23 21:50:00
這是您的'GridView'的完整標記嗎? – 2012-04-23 21:50:09