如何设置gridview的编辑按钮模式点击,而不是使用的CommandName [英] How to set gridview to edit mode on button click instead of using commandname
问题描述
大家好我有一个模板字段一个ItemTemplate如下:
Hi all I am having a template field as follows with an itemtemplate
<asp:TemplateField HeaderText="Edit/Delete">
<ItemTemplate>
<asp:LinkButton ID="lnkEdit" runat="server" Text="Edit" OnClick=lnkEdit_Click"> </asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
一般而言,而不是点击我们用写
事件的CommandName =编辑
和 OnRowEditing
情况下,我们将设置gridview的行具有以下code到编辑模式
Generally instead of Click
event we use to write CommandName="Edit"
and on OnRowEditing
event we will set gridview row to edit mode with the following code
protected void grdDemo_RowEditing(object sender, GridViewEditEventArgs e)
{
grdDemo.EditIndex = e.NewEditIndex;
bindGrid();
}
取而代之的是我会设置gridview的行编辑链接上单击按钮模式下,我们如何能做到这一点任何想法,请
Instead of this I would to set gridview row to edit mode on link button click, how can we do that any ideas please
推荐答案
有一些其他的选项可用,因为你想忽略的CommandName:)
There are couple of other option available since you wish to ignore the commandname :)
-
<一个href=\"http://stackoverflow.com/questions/7262409/click-anywhere-on-a-gridview-row-to-enter-the-edit-mode\">Click随时随地激活编辑模式的GridView
<一个href=\"http://stackoverflow.com/questions/438116/asp-net-gridview-how-to-activate-edit-mode-based-on-id-datakey\">Activate基于ID编辑模式 - Datakey
在EditIndex属性设置为适当的行,然后再重新绑定GridView控件到它的数据源。
Set the EditIndex property to the appropriate row and then ReBind the GridVIew again to it's DataSource.
protected void btnEdit_Click(object sender, EventArgs e)
{
GridView1.EditIndex = 1;
}
谷歌/冰更多..
Google/Bing for more..
这篇关于如何设置gridview的编辑按钮模式点击,而不是使用的CommandName的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!