Question:
<asp:GridView ID="GridView1" AutoGenerateColumns="False" DataKeyNames="Id"
runat="server" onrowediting="GridView1_RowEditing">
<Columns>
<asp:BoundField DataField="Id" HeaderText="ID" Visible="False" />
<asp:BoundField DataField="FirstName" HeaderText="First Name" />
<asp:BoundField DataField="LastName" HeaderText="Last Name" />
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ID="imageButton" AlternateText="Edit" CausesValidation="false" CommandName="Edit" runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
public partial class _Default : System.Web.UI.Page
{
public class Person
{
public string FirstName { get; set; }
public string LastName { get; set; }
public int Id { get; set; }
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
List<Person> people = new List<Person>() { new Person { FirstName = "Mike", Id = 1, LastName = "Myers" }, new Person() { FirstName = "John", Id = 2, LastName = "Smith" } };
GridView1.DataSource = people;
GridView1.DataBind();
}
}
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
}
}
Solution:
change this 'edit' to other string. ex. 'edit1'...
<asp:ImageButton ID="imageButton" AlternateText="Edit" CausesValidation="false" CommandName="Edit" runat="server" />
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/310974/viewspace-1985053/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/310974/viewspace-1985053/
本文介绍了一个ASP.NET GridView控件的使用示例,展示了如何设置GridView以显示包含姓名和ID的数据,并允许用户通过点击按钮来触发编辑操作。代码中包含了具体的实现细节。
3301

被折叠的 条评论
为什么被折叠?



