1

我有gridview一个sqldatasource包含 7 个值的值。gridview datakeynamesequipment_ID;_ 其余的是常规字段。

我正在尝试使用e.values("BME_No")within gridview_rowdeleted,但它是空的。同时,e.values("equipment_name")已满,e.values.count节目values是 5. values应该是 6,不包括datakeyname equipment_ID.

从这里的文章{没有提供网址},我看到datakeynames被排除在values. 另一方面,BME_No不是datakeyname

我应该如何进行?

sql数据源:

<asp:SqlDataSource ID="SqlDataSource_GV" runat="server" ConnectionString="<%$ ConnectionStrings:MedicalEquipmentLibrary_DBConnectionString %>"
        SelectCommand="Select_Equipments" SelectCommandType="StoredProcedure" UpdateCommand="Update_Equipment"
        UpdateCommandType="StoredProcedure" CancelSelectOnNullParameter="False" DeleteCommand="Delete_Equipment"
        DeleteCommandType="StoredProcedure">
        <SelectParameters>
            <asp:ControlParameter ControlID="txtSearch" Name="BME_No" PropertyName="Text" Type="Int32" />
        </SelectParameters>
        <DeleteParameters>
            <asp:Parameter Name="Equipment_ID" Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="Equipment_ID" Type="Int32" />
            <asp:Parameter Name="BME_No" Type="Int32" />
            <asp:Parameter Name="Equipment_Name" Type="String" />
            <asp:Parameter Name="Description" Type="String" />
            <asp:Parameter Name="Model_Name" Type="String" />
            <asp:Parameter Name="Vendor_Name" Type="String" />
            <asp:Parameter Name="Manufacture_Name" Type="String" />
        </UpdateParameters>
    </asp:SqlDataSource>

Gridview_rowdeleted 事件:

 Protected Sub GV_Main_RowDeleted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeletedEventArgs) Handles GV_Main.RowDeleted
        lblMessage.ForeColor = Drawing.Color.Red
        lblMessage.Visible = True
        lblMessage.Text = "Equipment " + e.Values("BME_No") + " is deleted."
    End Sub
4

1 回答 1

0
  • 如果该字段是绑定字段,请检查该列是否可见。
  • 如果是模板字段,请检查该字段是否为双向绑定。从文档

“只有在项目模板中使用双向绑定表达式时才会填充 Values 属性”

于 2015-05-19T13:11:30.947 回答