Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you're trying to do this in a form in code behind then you need to find the report viewer object and add an event to the RenderingComplete that implements Find, so something like this:</p> <pre><code>public Report() { InitializeComponent(); rpViewer.RenderingComplete += new RenderingCompleteEventHandler(rpViewer_RenderingComplete); } void rpViewer_RenderingComplete(object sender, RenderingCompleteEventArgs e) { int x = rpViewer.Find("0", 1); } </code></pre> <p><strong>EDIT:</strong></p> <p>So, since this in a webpage you can't use the WinForms Controls, however, I was able to wire up a little less hacked version using Javascript that klabranche had used.</p> <p>Here's a code behind class that adds a javascript function to the body of the html to search the report for the search text that you want:</p> <pre><code>private void SearchReport(ReportViewer rv, string SearchText) { TextBox txt = (TextBox)rv.Controls[1].Controls[4].Controls[0]; txt.Text = SearchText; this.Body.Attributes.Add("onload", "javascript:document.getElementById('" + rv.ClientID + "').ClientController.ActionHandler('Search', '" + SearchText + "');"); } </code></pre> <p>If you don't add the search text to the text box, then it won't show the search string in the text box on the report. This also only works for one report, so if you had additional reports you'd need to alter this. Also, for this to work you need to alter the body tag of your html:</p> <pre><code>&lt;body id="Body" runat="server"&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload