【发布时间】:2014-01-31 09:25:31
【问题描述】:
我有一个包含数据网格的接口。当我将元素添加到数据网格时,我还将它添加到列表属性中,该属性是我的数据网格的数据源。这里在代码隐藏中声明我的列表:
Public Property listeSpecialite() As List(Of RECSPECIALITECONCOURS)
Get
Return Session("specialite")
End Get
Set(ByVal value As List(Of RECSPECIALITECONCOURS))
Session("specialite") = value
End Set
End Property
这是我将元素添加到数据网格时的代码:
Protected Sub gridsecialite_ItemCommand(source As Object, e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles gridsecialite.ItemCommand
If e.CommandName = "Insert" Then
Dim dropSpecialite As DropDownList = CType(e.Item.FindControl("txtSpecialite_Footer"), DropDownList)
Dim specialite As New RECSPECIALITECONCOURS
specialite.CODESPECIALITE = IGS.ChercherParIdInt(Of GENSPECIALITE)(CInt(dropSpecialite.SelectedValue))
listeSpecialite.Add(specialite)
gridsecialite.DataSource = listeSpecialite
gridsecialite.DataBind()
End If
End Sub
在用户单击保存时,我将列表中的所有元素保存到数据库中。
如何在不使用会话的情况下保存列表元素。 (我的老板说在会话性能原因中存储元素列表不好)
【问题讨论】: