猿问

在GridView中显示列表

我有一个简单的字符串列表,已绑定到gridview:


List<string> directories = new List<string>();

    DirectoryGV.DataSource = directories;

    DirectoryGV.DataBind();


我想要GV上的选择按钮


如何访问列表中的数据以填充选择按钮?


什么是DataField名称?


<asp:Button ID="ImportBtn" runat="server"

    CommandName="Import"

    CommandArgument='<%# Eval("Item") %>'

    Text="'<%# "Import " + Eval("Item") %>" />


项目不是正确的字段名称,但是我找不到什么


翻过高山走不出你
浏览 163回答 1
1回答

噜噜哒

用 Container.DataItem<asp:GridView ID="GridView1" runat="server">&nbsp; &nbsp; <Columns>&nbsp; &nbsp; &nbsp; &nbsp; <asp:TemplateField>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ItemTemplate>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <%# Container.DataItem %>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <asp:Button ID="ImportBtn" runat="server" CommandName="Import"&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CommandArgument='<%# Container.DataItem %>'&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Text='<%# "Import " + Container.DataItem %>' />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </ItemTemplate>&nbsp; &nbsp; &nbsp; &nbsp; </asp:TemplateField>&nbsp; &nbsp; </Columns></asp:GridView>
随时随地看视频慕课网APP
我要回答