实体DataSource Where参数

时间:2013-06-06 15:33:59

标签: asp.net vb.net entitydatasource

我有实体数据源,我想添加一个参数,以便过滤信息。我有一个包含项目列表的gridview,在选中一个复选框并按下编辑按钮后,它会将您发送到另一个视图,其中有 detailsdatasource detailsview ,因为它是DS。现在实体数据源我想添加一个where参数。这就是我到目前为止......

        <asp:EntityDataSource ID="EntityDataSource2" runat="server" ConnectionString="name=sspEntities" DefaultContainerName="sspEntities" 
            EnableDelete="True" EnableFlattening="False" EnableInsert="True" EnableUpdate="True"
             EntitySetName="Salary_Increase_Type" AutoGenerateWhereClause="True">
        </asp:EntityDataSource>




  Protected Sub ImageButton3_Click(sender As Object, e As ImageClickEventArgs) Handles ImageButton3.Click
        For Each dr As GridViewRow In GridView1.Rows
            If ((TryCast(dr.FindControl("checkbox1"), CheckBox)).Checked = True) Then
                Dim id As Integer = GridView1.DataKeys(dr.RowIndex).Value
                EntityDataSource2.WhereParameters.Clear()

                EntityDataSource2.WhereParameters.Add(id, "id")
                MultiView1.ActiveViewIndex = 1
                DetailsView1.ChangeMode(DetailsViewMode.Edit)



            End If
        Next
    End Sub

1 个答案:

答案 0 :(得分:0)

EntityDataSource2.WhereParameters.Clear()EntityDataSource2.WhereParameters.Add(name:=“Id”,dbType:= DbType.Int32,value:= id)