下面是代码:
<asp:GridView ID="gviewEditDel" runat="server" AutoGenerateColumns="False" Width="400px" AllowPaging="True"
OnRowCancelingEdit="gviewEditDel_RowCancelingEdit"
OnRowDeleting="gviewEditDel_RowDeleting"
OnRowEditing="gviewEditDel_RowEditing"
OnRowUpdating="gviewEditDel_RowUpdating"
PageSize="5" >
<Columns>
<asp:TemplateField HeaderText="好友描述" SortExpression="FriendDesc">
<HeaderStyle Width="600px"/>
<EditItemTemplate>
<asp:TextBox ID="FriendDesc" runat="server" Text='<%# Bind("FriendDesc") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="FriendDesc" runat="server" Text='<%# Bind("FriendDesc") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="编辑好友" ShowHeader="False">
<HeaderStyle Width=200px/>
<EditItemTemplate>
<asp:LinkButton ID="Update" runat="server" CausesValidation="True" CommandName="Update"
Text="更新"></asp:LinkButton>
<asp:LinkButton ID="Cancel" runat="server" CausesValidation="False" CommandName="Cancel"
Text="取消"></asp:LinkButton>
</EditItemTemplate>
<ItemTemplate>
<asp:LinkButton ID="Edit" runat="server" CausesValidation="False" CommandName="Edit"
Text="编辑"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="删除好友" ShowHeader="False">
<HeaderStyle Width="150px" Font-Size=14pt />
<ItemTemplate>
<asp:LinkButton ID="Delete" runat="server" CausesValidation="False" CommandName="Delete"
Text="删除"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
cs中是:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
EditDelBind();//绑定的方法