sharepoint 2010 - Event Receiver not affecting until refesh the list -


i have sharepoint 2010 list. have written event receiver code update field value in item added event. getting correct result, it's not updating field value until refresh list. why?

code:

public override void itemadded(spitemeventproperties properties)        {        base.itemadded(properties);         spweb web = properties.openweb();        splist list = properties.list;        int highestvalue = 0;         spquery query = new spquery();        query.query = @"<orderby>                          <fieldref name='nextno' ascending='false' />                      </orderby><rowlimit>1</rowlimit>";         splistitemcollection itemcollection = list.getitems(query);        if (itemcollection.count > 0)        {            splistitem item = itemcollection[0];            highestvalue = convert.toint32(item["nextno"]);        }         splistitem curritem = properties.listitem;        curritem["nextno"] = highestvalue + 1;        curritem.update(); }       

you need use itemadding event receiver fires before list updated , show changes. itemadded event fires after list has been updated hence need refresh.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -