tags:

views:

132

answers:

0

Please help me,

I have a search page which i customized using sharepoint designer & wrote the server event handling code inline. I also build a custom ListViewWebPart to display the search results.

The SPQuery is generated based on the user input and its assigned to the custom ListViewWebPart by modifying the exposed custom property each time the user click on the search button.

I am using the following code to assigned the generated CAML query to custom web part property, but I get the checkout document error.

So I put the condition using SPFile.GetLimitedWebPartManager(Shared Scope) if SPFile.CheckOutStatus is none then SPFile.Checkout(); else SPFile.UndoCheckOut(); I did this when the error occured but later that error disappeared so removed those line from the code

Now the code looks like following

protected void assignQuerytoWP(string query) { try { SPWeb web = SPContext.Current.Web; SPFile file = web.GetFile(web.Url + "/Default.aspx");

SPLimitedWebPartManager webpartManager = file.GetLimitedWebPartManager(System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);

SPLimitedWebPartCollection webparts = webpartManager.WebParts;

ContractsManagementWP wp = null;

foreach (System.Web.UI.WebControls.WebParts.WebPart mywp in webpartManager.WebParts) {

if (mywp.Title == "ContractsManagementWP Web Part")
{
   wp = (ContractsManagementWP)mywp;
}

}

wp.FilterQuery = query; wp.ListToLink = "Contracts"; wp.ViewOfSourceList = "All Documents WP"; webpartManager.SaveChanges(wp); web.Update();
Response.Redirect(web.Url + "/Default.aspx" );
}

catch(Exception ex){Response.Write(ex.Message);

} }

My problem is when the user click the search button the query is assigned to the web part property, but I cann't see the results in the listview webpart unless I refersh the page again infact it should display as soon as the user clicks on the search button (its a asp.net button control runat server)

So I used Response.Redirect(samepage) to redirect to the same page and reload the values on the search controls by saving/loading the search inputs back to the controls by using session variables.

Can you please advice me what I am doing is correct or what should I do to display the results as soon as the user click the search button or whats the right way to display the results?

Abdul Afroze [email protected]