Hi all,

I have a custom people search web part which uses a simple form, SPGrid and a 
DataTable.

[cid:[email protected]]

I'd like to extend this so that people can search for staff from another page 
via a Search Box.

[cid:[email protected]] ...where k="Paul"...

What I want to do is:


1.       Check if the "k" param has a value.

2.       Use it in my query and apply it to the datasource's filter expression.

3.       Clear the query string on postback.

I've added the following to the OnLoad event but it throws a NullReference 
exception.

Any help appreciated.

// Get URL and check for "k" query string param in case of search from another 
page
String txtNameFromQuery = HttpContext.Current.Request.QueryString["k"];

if(!String.IsNullOrEmpty(txtNameFromQuery))
{
       // Set txtName field to query string value for additional searches
       txtName.Text = txtNameFromQuery;

       // Define the search query
       String q = "Name LIKE '%" + txtNameFromQuery + "%'";

       // Apply query to filterexpression
       ds.FilterExpression = q;
       ViewState["FilterExpression"] = (String)ds.FilterExpression;

       // Remove any query string parameters from the URL
       HttpContext.Current.Request.QueryString.Clear();
}

Regards,

Paul


The content of this email is confidential to the intended recipient at the 
email address to which it has been addressed. It may not be disclosed to, or 
used by, anyone other than this addressee, nor may it be copied in any way. If 
received in error, please contact the author and then delete the message from 
your system. 
Please note that neither Keller Australia nor the sender accepts any 
responsibility for viruses and it is your responsibility to scan the email and 
attachments (if any).
Visit http://www.keller.com.au/ for more information. 

--------------------------------------------------------------------------------
This e-mail message has been scanned for Viruses and Content and cleared by 
MailMarshal 
--------------------------------------------------------------------------------
_______________________________________________
Sponsored by Infotext - Amazing Search for Microsoft SharePoint - 
http://www.infotext.com/
ozmoss mailing list
[email protected]
http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss

Reply via email to