hi
I use below code to save session into database:
<sessionState mode="SQLServer" allowCustomSqlDatabase="true" timeout="1440" sqlConnectionString="Data Source=.;Initial Catalog=ASPState;User ID=sa;Password=2008"/>
and I have datalist in page below are codes:
<asp:DataList ID="DLclass" runat="server">
<ItemTemplate>
<asp:LinkButton ID="Linkbtnclass" runat="server" CssClass="lbldasteM" CommandArgument='<%# Eval("Name") %>'
OnClick="Linkbtnclass_Click"><%# Eval("Name") %></asp:LinkButton>
<div id="MM31">
</div>
</ItemTemplate>
</asp:DataList>
protected void Linkbtnclass_Click(object sender, EventArgs e)
{
rptPager.Visible = !(rptPager2.Visible = true);
ViewState["LinkButtonValue"] = (sender as LinkButton).CommandArgument;
this.GetCustomersPageWiseMC(1, (sender as LinkButton).CommandArgument);
item = (DataListItem)(sender as LinkButton).NamingContainer;
//Session["Item"] = item;
hdnFieldID.Value = (sender as LinkButton).CommandArgument;
Session["selctedMenuHtml"] = hdnFieldID.Value;
(item.FindControl("Linkbtnclass") as LinkButton).ForeColor = ColorTranslator.FromHtml("#fb00c2");
string Id = (item.FindControl("Linkbtnclass") as LinkButton).UniqueID;
}
and I add :
[Serializable()]
public partial class _Default : System.Web.UI.Page
{
but when I click linkbutton from datalist it will shoe this error:
Unable to serialize the session state. In 'StateServer' and 'SQLServer' mode, ASP.NET will serialize the session state objects, and as a result non-serializable objects or MarshalByRef objects are not permitted. The same restriction applies if similar serialization is done by the custom session state store in 'Custom' mode.
what should I do?
Best regards
neda