带命令按钮的Gridview [英] Gridview with command Button
本文介绍了带命令按钮的Gridview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在带有按钮的页面中具有gridview.
我想在用户单击按钮时执行查询,然后应删除该行.
我正在尝试演示,但无法正常工作.
I have gridview in a page with button.
i want to execute a query when user click button and then that row should be deleted.
I was trying a demo but it is not working.
<asp:GridView ID="GridView1" runat="server"
onselectedindexchanged="GridView1_SelectedIndexChanged">
<Columns>
<asp:TemplateField HeaderText="Delete" HeaderStyle-CssClass="title_bg" ItemStyle-HorizontalAlign="Center">
<asp:LinkButton ID="lkDelte" runat="server" OnClientClick="return confirm('Are you sure you want to delete?')"
CommandArgument="<%# ((GridViewRow) Container).RowIndex %>"
CommandName="y" ><img src="Images/A5.gif" alt="Delete" border="0" /></asp:LinkButton>
</ItemTemplate>
<pre lang="xml"><asp:ButtonField CommandName="Updateit" Text="Button" />
</Columns></asp:GridView>
代码:
void GridView1_RowCommand(Object sender,GridViewCommandEventArgs e)
{
如果(e.CommandName =="y")
{
Response.Write("hello");
}
}
朋友们请帮助我....!!!
code:
void GridView1_RowCommand(Object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "y")
{
Response.Write("hello");
}
}
Friends Please Help Me....!!!
推荐答案
ohhhh ,,
我很想念
Aspx页面中的OnRowCommand ="GridView1_RowCommand".
ohhhh ,,
I was missing
OnRowCommand="GridView1_RowCommand" in aspx page.
这篇关于带命令按钮的Gridview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文