English 中文(简体)
停止原有会议名单反对添加
原标题:stop old session list object to add up

我的以下守则是:客户手册使用网络服务方法,编制通用名单,然后将其储存到会议。

 [WebMethod(EnableSession = true)]
public void SaveUserSelection(string slctdRooms, string slctdcst)
{
    List<SelectRms> SelectR = Session["someinfo"] as List<SelectRms>;
    if (SelectR  == null)
    { 
        SelectR = new List<SelectRms>();
        Session["someinfo"] = SelectR;

    }

    SelectR.Add(new SelectRms { roomtype = slctdRooms, Roomcst = slctdcst });

}

然后,我要提醒本届会议,将数据放在另一页如上。

清单(SlctdRmWebSrv.SelectRms)

       if(SelctdRM != null)


        {

            repeater1.DataSource = SelctdRM;

             repeater1.DataBind();
        }

问题是,每当我提醒本届会议不要制定新的清单时,新数据就加到旧数据。 我只想看到目前数据。 我试图清除名单,放弃会议,或在添加新内容之前清除重复;容易做到这一点。 许多感谢<>。

最佳回答

象你这样说,你多次用手法打上<条码>。 如果是这样的话,那么你名单的首次才开始。

因此,你的名单将保留在“旧”名单上,因为名单尚未确定或重新开始。

可能的话,请将初始化成一种单独的方法(请上Page_Load/code>,或创建一个新的WebMethod,仅以明确/初步确定清单。 例如,这是你决定将其列入<代码”的方法。 页: 1 活动:

private void Page_Load(object sender, System.EventArgs e)
{
  if(!Page.IsPostBack)
    Session["someinfo"] =  new List<SelectRms>();  
}

这正是你创建<条码”的方法。 WebMethod:

[WebMethod(EnableSession = true)]
public void InitUserSelection()
{
  Session["someinfo"] =  new List<SelectRms>();
}

在你准备随时追踪用户选择时使用这种方法。 或许当你的形式最初负荷时(将这一文字放在网页底部):

$(document).ready(function() {
  $.ajax({
  type: "POST",
  url: "PageName.aspx/InitUserSelection",
  data: "{}",
  contentType: "application/json; charset=utf-8",
  dataType: "json",
  success: function(msg) {
    // After init you could use this method to do something else
  }
});
});

http://www.ohchr.org。

[WebMethod(EnableSession = true)]
public void SaveUserSelection(string slctdRooms, string slctdcst)
{
  List<SelectRms> SelectR = Session["someinfo"] as List<SelectRms>;
  if (SelectR  != null)
    SelectR.Add(new SelectRms { roomtype = slctdRooms, Roomcst = slctdcst });
}

而这正是你在选择改变时所想的:

$.ajax({
  type: "POST",
  url: "PageName.aspx/SaveUserSelection",
  data: "{ slctdRooms : Value1 , slctdcst : Value2 }",
  contentType: "application/json; charset=utf-8",
  dataType: "json",
  success: function(msg) {
   //your list was updated, you may do something afterwards
  }
});
问题回答

@Ulises。 这是我做的事情:

public  List<SelectRms> GetUserContent()
    {
        List<SelectRms> SelectR=new List<SelectRms>();
        Session["someinfo"] = SelectR;
        return Session["someinfo"] as List<SelectRms>;
    }


    [WebMethod(EnableSession = true)]
    public void SaveUserSelection(string slctdRooms, string slctdcst)
    {
        List<SelectRms> SelectR = GetUserContent();
        SelectR.Add(new SelectRms { roomtype = slctdRooms, Roomcst = slctdcst });

    }

但是,它只是回到我名单上的单一(第一)部分,而不是整个清单,任何帮助都是这样。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!