[英]Can't add button column in asp.net gridview
Here is my the code for my gridview 这是我的GridView代码
<asp:GridView ID="gvPredstave" runat="server" CssClass="gridview" AlternatingRowStyle-CssClass="even" AutoGenerateColumns="True">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="btnGetInfo" runat="server"Text="GetInfo" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
When i start my app and try to open this page I am getting an error in line where is button defined with message: 当我启动我的应用程序并尝试打开此页面时,出现错误消息,该行的按钮定义为消息:
The server tag is not well formed
Does anybody know the problem? 有人知道这个问题吗?
PS I am using Visual Studio 2010 PS我正在使用Visual Studio 2010
This might be is (I just verified it) your problem: 这
可能是(我刚刚验证了)您的问题:
runat="server"Text="GetInfo"
Try changing it to: 尝试将其更改为:
runat="server" Text="GetInfo"
Add a space after "server" in <asp:Button
line: 在
<asp:Button
行的“服务器”之后添加一个空格:
<asp:Button ID="btnGetInfo" runat="server" Text="GetInfo" />
You may need set the CommandArgument
and CommandName
properties: 您可能需要设置
CommandArgument
和CommandName
属性:
<asp:Button ID="btnGetInfo" runat="server" Text="GetInfo" CommandArgument='<%# Eval("Primary_field") %>' CommandName='GetInfo' />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.