【问题标题】:Editing a gridview using the updating event in VB.net使用 VB.net 中的更新事件编辑网格视图
【发布时间】:2011-11-18 14:56:56
【问题描述】:

我试图完成的是尝试使用更新事件来编辑网格视图,但不确定如何执行此操作。我填充数据网格的方式是将其放入数据集中并将其用作数据源并进行数据绑定。这是我下面的数据网格。任何帮助都会非常有帮助。

  <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false">
        <Columns>
            <asp:BoundField DataField="AIRCRAFT" HeaderText="ProductID" />
            <asp:BoundField DataField="ENGINE" HeaderText="Product" />
            <asp:BoundField DataField="LEMAC" HeaderText="Price" />

            <asp:CommandField ShowEditButton="true" />
        </Columns>
        <SelectedRowStyle BackColor="#99CCFF" />
    </asp:GridView>

【问题讨论】:

    标签: asp.net vb.net


    【解决方案1】:

    当用户点击“更新”按钮时,页面会进行回发,然后更改相关行的控件,从而允许更新。

    此外,它还启用了 2 个按钮:更新和取消。

    取消,将使 GridView 保持第一次单击之前的状态。 更新,会将用户修改的数据发送到保存。

    为了允许更新,您必须捕获 RowUpdating 事件。像这样的:

    Protected Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As GridViewUpdateEventArgs) Handles GridView1.RowUpdating
    ' Do your Update here
    End Sub
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-21
      相关资源
      最近更新 更多