在我的应用程序中,我只有一个可编辑列,如果该可编辑列为空,我需要显示添加链接按钮,但它显示编辑链接按钮。如果gridview中的特定可编辑列是,我如何显示添加为链接按钮空
<asp:TemplateField>
<itemtemplate>
<asp:Button Visible='<%# string.IsNullOrEmpty() %>' runat="server" Text="Edit" ID="Edit" CommandName="Edit" />
<asp:Button Visible='<%# !string.IsNullOrEmpty() %>' runat="server" Text="Add" ID="Add" CommandName="Edit" />
</itemtemplate>
</asp:TemplateField>
我试过这个,但它正在运行,但无法编辑
答案 0 :(得分:0)
最简单的方法是使用2个按钮向GridView添加TemplateField
,这些按钮具有基于列值的可见性。
<asp:TemplateField>
<itemtemplate>
<asp:Button Visible='<%# string.IsNullOrEmpty(Eval("editableField").ToString()) %>' runat="server" Text="Edit" ID="Edit" CommandName="Edit" />
<asp:Button Visible='<%# !string.IsNullOrEmpty(Eval("editableField").ToString()) %>' runat="server" Text="Add" ID="Add" CommandName="Edit" />
</itemtemplate>
</asp:TemplateField>