2013-10-27 42 views
1

我有ASP的GridView我的ASP GridView控件沒有顯示它的項目

<asp:GridView ID="uploadedSoundDataGridView" runat="server" AutoGenerateColumns="false"  EmptyDataText = "No files uploaded"/> 

,並在頁面加載一些代碼在目錄中顯示文件

if (!IsPostBack) 
     { 
      string[] filePaths = Directory.GetFiles(Server.MapPath("~/Uploads/")); 
      List<ListItem> files = new List<ListItem>(); 
      foreach (string filePath in filePaths) 
      { 
       files.Add(new ListItem(Path.GetFileName(filePath), filePath)); 
      } 
      uploadedSoundDataGridView.DataSource = files; 
      uploadedSoundDataGridView.DataBind(); 
     } 

我可以把所有的文件名,我可以將它們綁定到GridView(我用quickwatch檢查過)。但在我的頁面,我不能看到GridView。有誰告訴我爲什麼?謝謝

+0

在GridView的標記集'的AutoGenerateColumns = 「真」'。 – afzalulh

回答

1

在你的GridView更改此屬性:

AutoGenerateColumns = "false" 

到:

AutoGenerateColumns = "true" 
+0

像一個魅力工作,謝謝你 –

相關問題