Filter a sharepoint visual web part through created by column through code -
i created visual web part , loading list in grid. when user login has display items created user a. user b has display items belong user b. here code have written.it display items irrespective of logged in user. can 1 me on this
public void displaylistdata() { // system.diagnostics.debugger.break(); datatable dt = new datatable(); var ospweb = spcontext.current.web; splist osplist = ospweb.lists["participation @ glance"]; string strcreatedby = spcontext.current.web.author.name; spquery oquery = new spquery(); oquery.query = "<query><where><eq><fieldref name='author' /><value type='user'>" + strcreatedby + "</value></eq></where></query>"; splistitemcollection colllistitems = osplist.getitems(oquery); datatable dts = colllistitems.getdatatable(); if (dts != null) { gridview1.gridlines = gridlines.none; gridview1.datasource = dts; gridview1.databind(); controls.add(gridview1); } else`enter code here` { lbl_noact.visible = true; lbl_noact.text = "we apologize there no times available."; } }
hi have fixed changing camel query below. data type user when changed string works charm :-)
datatable dt = new datatable(); var ospweb = spcontext.current.web; splist osplist = ospweb.lists["participation @ glance"]; string strcreatedby = spcontext.current.web.currentuser.name; spquery oquery = new spquery(); oquery.query = @"<where><eq><fieldref name='author' /><value type='string'>" + strcreatedby + "</value></eq></where>"; splistitemcollection colllistitems = osplist.getitems(oquery);
Comments
Post a Comment