//修改按钮
        protected void EditGrid_EditCommand(object source, DataGridCommandEventArgs e)
        {            
            Alert("aaaaaaaaa");
            EditGrid.EditItemIndex = e.Item.ItemIndex;
            Bind_EditGrid();
        }        //更新按钮
        protected void EditGrid_UpdateCommand(object source, DataGridCommandEventArgs e)
        {
            Alert("ssssssss");
        }  在做一个编辑GridView 中的单元格的功能,但是每次点更新按钮时加断点,总是跳到EditCommand里,也就是弹出aaaaaaaa,什么原因啊?   求救!!!!

解决方案 »

  1.   

    因为每次提交的时候  EditCommand要比UpdateCommand 先执行。在EditCommand做个判断吧
      

  2.   

      我还没见过能卡成这样的!
      呵呵,当然不是啦!
      就是不知道什么原因! 前台代码如下::
                  <cc1:HtDataGrid ID="EditGrid" runat="server" AllowSorting="True" AutoGenerateColumns="False"
                CellPadding="4" CssClass="datagrid" Width="800px" Font-Size="12px" ForeColor="#333333"
                GridLines="None" PageSize="50" OnEditCommand="EditGrid_EditCommand" OnUpdateCommand="EditGrid_UpdateCommand"
                OnCancelCommand="EditGrid_CancelCommand">
                <Columns>
                    <asp:TemplateColumn HeaderText="序号">
                        <ItemTemplate>
                            <asp:Label ID="Label1" runat="server" Text='<%# (int)(DataBinder.Eval(Container, "DataSetIndex")) + 1 %>'></asp:Label>
                        </ItemTemplate>
                        <HeaderStyle Wrap="false" />
                    </asp:TemplateColumn>
                    <asp:TemplateColumn HeaderText="名片产品名称">
                        <ItemTemplate>
                            <asp:Label ID="lblHRowID" runat="server" Text='<%# Eval("RowID")%>' Visible="false"></asp:Label>
                            <asp:Label ID="lblHCode" runat="server" Text='<%# Eval("SpecificationCode")%>' Visible="false"></asp:Label>
                            <%--<asp:Label ID="lblDistrictCode" runat="server" Text='<%# Eval("DistrictCode")%>' Visible="false"></asp:Label>--%>
                            <asp:Label ID="lblProductName" runat="server" Text='<%# Eval("ProductName")%>'></asp:Label>
                        </ItemTemplate>
                        <HeaderStyle Wrap="false" />
                    </asp:TemplateColumn>
                    <asp:TemplateColumn HeaderText="基础价格">
                        <ItemTemplate>
                            <asp:Label ID="lblBasePrice" runat="server" Text='<%# DataBinder.Eval(Container,"DataItem.BasePrice", "{0:c}")%>'></asp:Label>
                        </ItemTemplate>
                        <HeaderStyle Wrap="false" />
                    </asp:TemplateColumn>
                    <asp:TemplateColumn HeaderText="区域价格">
                        <ItemTemplate>
                            <asp:Label ID="Label2" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.AreaPrice", "{0:c}") %>'></asp:Label>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox runat="server" onkeyup="test(this);" ID="txtAreaPrice" Text='<%# DataBinder.Eval(Container, "DataItem.AreaPrice", "{0:F2}") %>'></asp:TextBox>
                        </EditItemTemplate>
                    </asp:TemplateColumn>
                    <asp:EditCommandColumn ButtonType="LinkButton" UpdateText="保存" EditText="修改" CancelText="取消"
                        HeaderText="修改"></asp:EditCommandColumn>
                </Columns>
            </cc1:HtDataGrid>
      

  3.   

    建议用这个方法来做gridview的编辑修改功能
        protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
        {
            GridView1.EditIndex = e.NewEditIndex;
        }    protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
        {
            GridView1.EditIndex = -1;
        }    protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {    }
      

  4.   

    cc1:HtDataGrid 是写好的GridView RowEditing事件都没有!
      

  5.   

    找到错误了,是因为我在 这里绑定了Grid    protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e) 
        { 
            GridView1.EditIndex = e.NewEditIndex; 
            Bind_EditGrid();
        } 
    而在   Bind_EditGrid() 方法里面
               protected void Bind_EditGrid()
            {
                DataTable dt = new DataTable();
                //根据会员简称查询会员编号
                dt = bllp.LoadProductsByMemberShortName(dalCustomerID.Text);
                if (dt != null)
                {
                    GridEdit.DataSource = dt;
                    GridEdit.DataBind();
                }
                else
                {
                    WebUtility.Alert("当前无数据!");
                }
                GridEdit.EditItemIndex = -1; //每次绑定都给他初始化一次,所以跳不到RowUpdating 事件里!
            }