遇到很奇怪的问题了,大家来看一看
GridView为什么丢失事件了,我重新放在一个页面里面,也会把事件丢失,谁知道怎么解决这个问题? --------------------编程问答-------------------- 谁来帮助我看一看,这个问题怎么解决啊? --------------------编程问答-------------------- 没有人遇到这样的问题吗?难道是我倒霉 --------------------编程问答-------------------- 你怎么确定是丢失的?断点跟踪了吗? --------------------编程问答-------------------- <asp:TemplateField ShowHeader="False"><ItemStyle HorizontalAlign="Center" Width="100px" />
<ItemTemplate>
<asp:Button ID="Button1" runat="server" CausesValidation="False" CommandName="Delete"
Text="删除" OnClientClick="return confirm('确认要删除吗?如果选择确定,该目录下面全部文章将删除!');" />
</ItemTemplate>
</asp:TemplateField>\
我点是,没有反应 --------------------编程问答-------------------- GridView1_RowUpdating这个也没有反应,别的是好的 --------------------编程问答-------------------- 我顶上去 --------------------编程问答-------------------- 如果用 这个 CommandName="Delete"
就用
RowCommand 事件
Example:
-----AspxCode----
在GridView加事件
OnRowCommand="CustGridView1_RowCommand"
-----CS代码------
protected void CustGridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Delete")
{
.....
}
} --------------------编程问答-------------------- 新创建一个页面试试吧. --------------------编程问答-------------------- 新加一个页面是不行的,我试哈上面那位朋友说的办法看看 --------------------编程问答--------------------
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
}
删除事件下 加个这个试试! --------------------编程问答-------------------- 朋友,我加了还是没有反应 --------------------编程问答-------------------- GridView1_RowUpdating也没有反应,别的好像可以.
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="3" DataKeyNames="id" GridLines="None" Width="437px" BackColor="White" BorderColor="White" BorderStyle="Ridge" BorderWidth="2px" CellSpacing="1" OnRowCancelingEdit="GridView1_RowCancelingEdit" OnRowDataBound="GridView1_RowDataBound" OnRowDeleting="GridView1_RowDeleting" OnRowEditing="GridView1_RowEditing" OnRowUpdating="GridView1_RowUpdating" OnSelectedIndexChanging="GridView1_SelectedIndexChanging" OnRowCommand="GridView1_RowCommand">
<FooterStyle BackColor="#C6C3C6" ForeColor="Black" />
<Columns>
<asp:TemplateField HeaderText="类别名称" ShowHeader="False">
<ItemStyle HorizontalAlign="Center" ForeColor="Black" />
<ItemTemplate>
<asp:LinkButton ID="LinkButton2" ForeColor=Black runat="server" CausesValidation="False" CommandName="Select"
Text='<%# Eval("name") %>'></asp:LinkButton>
</ItemTemplate>
<FooterStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField HeaderText="修改区">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</EditItemTemplate>
<ItemStyle HorizontalAlign="Center" />
<ItemTemplate>
<asp:Label ID="Label1" runat="server"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField ButtonType="Button" InsertText="" NewText="" SelectText="" ShowEditButton="True" DeleteText="" >
<ItemStyle HorizontalAlign="Center" />
</asp:CommandField>
<asp:TemplateField ShowHeader="False">
<ItemStyle HorizontalAlign="Center" Width="100px" />
<ItemTemplate>
<asp:Button ID="Button1" runat="server" CausesValidation="False" CommandName="Delete"
Text="删除" OnClientClick="return confirm('确认要删除吗?如果选择确定,该目录下面全部文章将删除!');" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<RowStyle BackColor="#DEDFDE" ForeColor="Black" />
<SelectedRowStyle BackColor="#9471DE" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#C6C3C6" ForeColor="Black" HorizontalAlign="Right" />
<HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#E7E7FF" />
</asp:GridView> --------------------编程问答-------------------- 朋友,加油 --------------------编程问答-------------------- 没人了吗? --------------------编程问答-------------------- 换个关键字试试,不用Delete比如用Dele
然后用RowCommand=Dele来找事件
-----CS代码------
protected void CustGridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Dele")
{
.....
}
}
补充:.NET技术 , ASP.NET