title: How to search and display names of file in a textbox and open the file by selecting it?
body: <p>I am searching for files in a folder and displaying the names of file in a textbox but now there is a problem. I would like to open a specific file by selecting it from the textbox. How can I achieve that? This is what I tried so far.</p>
  
  
  
  <pre><code>&lt;%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %&gt;
  
  &lt;!DOCTYPE html&gt;
  
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head id="Head1" runat="server"&gt;
      &lt;script type="text/javascript" src="Reports/PageLoad.js"&gt;&lt;/script&gt;
      &lt;title&gt;&lt;/title&gt;
      &lt;link href="Styles/Site.css" rel="stylesheet" type="text/css" /&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form id="form1" runat="server"&gt;
       &lt;div&gt;
           &lt;telerik:RadScriptManager ID="RadScriptManager1" runat="server" /&gt;
              &lt;div style="width: 100%; height: 100%; margin-top: 12px;"&gt;
                  &lt;asp:HiddenField ID="hdoperatorid" runat="server" /&gt;
                  &lt;asp:HiddenField ID="hdbankid" runat="server" /&gt;
                  &lt;asp:HiddenField ID="hdCountry" runat="server" /&gt;
                  &lt;table border="0" cellpadding="0" cellspacing="0" style="width: 100%; height: 100%;"
                      id="mainContent"&gt;
                      &lt;tr&gt;
                          &lt;td valign="top" style="width: 70%;" class="BorderFrame"&gt;
                              &lt;table style="width: 100%; border: 2px solid; border-radius: 5px; border-color: #005cb9;" cellpadding="0" cellspacing="0"&gt;
                                  &lt;tr&gt;
                                      &lt;td class="HeadingText" colspan="4"&gt;
                                          &lt;asp:Label ID="Label12" runat="server"
                                              Text="File Logs"&gt;&lt;/asp:Label&gt;
                                      &lt;/td&gt;
                                  &lt;/tr&gt;
                                  &lt;tr&gt;
                                      &lt;td colspan="4"&gt;
                                          &lt;table style="width: 100%; border: 2px solid; border-radius: 5px; border-color: #005cb9;" cellpadding="0" cellspacing="0"&gt;
  
  
                                              &lt;tr&gt;
                                                  &lt;td colspan="4" class="HeadingText"&gt;
                                                      &lt;asp:Label ID="Label16" Width="100%" runat="server" Text="Enter Details"&gt; &lt;/asp:Label&gt;
                                                  &lt;/td&gt;
                                              &lt;/tr&gt;
                                              &lt;tr&gt;
                                  &lt;td class="label"&gt;
                                      &lt;asp:Label ID="lblCountry" runat="server" Text="Select Country" Width="200px" CssClass="LableText"&gt;&lt;/asp:Label&gt;
                                  &lt;/td&gt;
                                  &lt;td&gt;
                                      &lt;asp:DropDownList id="ddlCountry" runat="server" AutoPostBack="True"  Width="200px"&gt;
                                       &lt;/asp:DropDownList&gt;
                                  &lt;/td&gt;
                                   &lt;/tr&gt;
                                              &lt;tr&gt;
                                  &lt;td class="label"&gt;
                                      &lt;asp:Label ID="lblLogType" runat="server" Text="Select Log Type" Width="200px" CssClass="LableText"&gt;&lt;/asp:Label&gt;
                                  &lt;/td&gt;
                                  &lt;td&gt;
                                      &lt;asp:DropDownList id="ddlLogType" runat="server" AutoPostBack="True"  Width="200px"&gt;
                                       &lt;/asp:DropDownList&gt;
                                      &lt;%--&lt;asp:DropDownList id="ddlLogType" runat="server"  Width="200px"&gt;
                                          &lt;asp:ListItem&gt;ElmaCore&lt;/asp:ListItem&gt;
                                         &lt;asp:ListItem&gt;ElmaCore&lt;/asp:ListItem&gt;
                                       &lt;/asp:DropDownList&gt;--%&gt;
                                  &lt;/td&gt;
                                   &lt;/tr&gt;
                                   &lt;tr&gt;
                                  &lt;td class="label"&gt;
                                      &lt;asp:Label ID="lblDate" runat="server" Text="Date" Width="200px" CssClass="LableText"&gt;&lt;/asp:Label&gt;
                                  &lt;/td&gt;
                                  &lt;td&gt;
                                      &lt;telerik:RadDatePicker ID="dtDate"  Width="200px" runat="server"&gt;
                                          &lt;Calendar ID="Calendar1" runat="server" UseColumnHeadersAsSelectors="False" UseRowHeadersAsSelectors="False"
                                              ViewSelectorText="x"&gt;
                                          &lt;/Calendar&gt;
                                          &lt;DateInput ID="DateInput1" runat="server" DateFormat="dd/MMM/yyyy" DisplayDateFormat="dd/MMM/yyyy"&gt;
                                          &lt;/DateInput&gt;
                                      &lt;/telerik:RadDatePicker&gt;
                                  &lt;/td&gt;
                                   &lt;/tr&gt;
                                  &lt;tr&gt;
                                  &lt;td class="label"&gt;
                                      &lt;asp:Label ID="lblReference" runat="server" Text="Reference" Width="200px" CssClass="LableText"&gt;&lt;/asp:Label&gt;
                                  &lt;/td&gt;
                                  &lt;td class="txtbox"&gt;
                                     &lt;asp:TextBox ID="txtReference" ReadOnly="false" Width="200px" runat="server" CssClass="textboxbook"&gt;&lt;/asp:TextBox&gt;
  
                                  &lt;/td&gt;
                                   &lt;/tr&gt;
  
  
                                          &lt;/table&gt;
                                      &lt;/td&gt;
  
                                  &lt;/tr&gt;
                                  &lt;tr&gt;
                                      &lt;td colspan="4"&gt;
                                          &lt;asp:Label ID="lblMessageLine" Width="100%" Height="20px" runat="server" CssClass="BottomDisplayMsg" /&gt;
                                      &lt;/td&gt;
                                  &lt;/tr&gt;
  
                                 &lt;tr&gt;
                                      &lt;td colspan="4" class="HeadingText"&gt;
                                          &lt;asp:Label ID="Label7" runat="server" Text="File Contents"&gt;&lt;/asp:Label&gt;
                                      &lt;/td&gt;
                                  &lt;/tr&gt;
                                  &lt;tr&gt;
                                      &lt;td colspan="4"&gt;
                                          &lt;asp:TextBox id="txtContents" runat="server"  Width="1200px" CssClass="textboxbook" TextMode="MultiLine" Height="300" /&gt;
                                          &lt;%--&lt;telerik:RadGrid ID="grdContents" runat="server" Height="180px" AutoGenerateColumns="true"
                                              GridLines="None"&gt;
                                              &lt;ClientSettings EnablePostBackOnRowClick="true"&gt;
                                                  &lt;Selecting AllowRowSelect="true" /&gt;
                                                  &lt;Scrolling AllowScroll="True" UseStaticHeaders="true" /&gt;
                                              &lt;/ClientSettings&gt;
                                              &lt;%--&lt;MasterTableView DataKeyNames="Country,BankID,FirstName,MiddleName,LastName,Mobile,Email,Address,City,Account,Title,IDNO"&gt;
                                                  &lt;Columns&gt;
                                                      &lt;telerik:GridBoundColumn DataField="Country" HeaderText="Country" UniqueName="Country" DefaultInsertValue=""&gt;
                                                      &lt;/telerik:GridBoundColumn&gt;
                                                      &lt;telerik:GridBoundColumn DataField="BankID" HeaderText="BankID" UniqueName="BankID" DefaultInsertValue=""&gt;
                                                      &lt;/telerik:GridBoundColumn&gt;
                                                      &lt;telerik:GridBoundColumn DataField="FirstName" HeaderText="FirstName" UniqueName="FirstName" DefaultInsertValue=""&gt;
                                                      &lt;/telerik:GridBoundColumn&gt;
                                                      &lt;telerik:GridBoundColumn DataField="MiddleName" HeaderText="MiddleName" UniqueName="MiddleName" DefaultInsertValue=""&gt;
                                                      &lt;/telerik:GridBoundColumn&gt;
                                                      &lt;telerik:GridBoundColumn DataField="LastName" HeaderText="LastName" UniqueName="LastName" DefaultInsertValue=""&gt;
                                                      &lt;/telerik:GridBoundColumn&gt;
                                                      &lt;telerik:GridBoundColumn DataField="Mobile" HeaderText="Mobile" UniqueName="Mobile" DefaultInsertValue=""&gt;
                                                      &lt;/telerik:GridBoundColumn&gt;
                                                      &lt;telerik:GridBoundColumn DataField="Email" HeaderText="Email" UniqueName="Email" DefaultInsertValue=""&gt;
                                                      &lt;/telerik:GridBoundColumn&gt;
                                                      &lt;telerik:GridBoundColumn DataField="Address" HeaderText="Address" UniqueName="Address" DefaultInsertValue=""&gt;
                                                      &lt;/telerik:GridBoundColumn&gt;
                                                      &lt;telerik:GridBoundColumn DataField="City" HeaderText="City" UniqueName="City" DefaultInsertValue=""&gt;
                                                      &lt;/telerik:GridBoundColumn&gt;
                                                      &lt;telerik:GridBoundColumn DataField="Account" HeaderText="Account" UniqueName="Account" DefaultInsertValue=""&gt;
                                                      &lt;/telerik:GridBoundColumn&gt;
                                                      &lt;telerik:GridBoundColumn DataField="Title" HeaderText="Title" UniqueName="Title" DefaultInsertValue=""&gt;
                                                      &lt;/telerik:GridBoundColumn&gt;
                                                      &lt;telerik:GridBoundColumn DataField="IDNO" HeaderText="IDNO" UniqueName="IDNO" DefaultInsertValue=""&gt;
                                                      &lt;/telerik:GridBoundColumn&gt;
                                                  &lt;/Columns&gt;
                                              &lt;/MasterTableView&gt;-%&gt;
                                          &lt;/telerik:RadGrid&gt;--%&gt;
                                      &lt;/td&gt;
                                  &lt;/tr&gt;
                              &lt;/table&gt;
                          &lt;/td&gt;
                          &lt;td style="width: 10%;" align="center" valign="bottom" class="BorderFrame"&gt;
                              &lt;table style="width: 100%;"&gt;
                                  &lt;tr&gt;
                                     &lt;td style="text-align: right"&gt;
                                                  &lt;asp:Button ID="cmdAdd" Width="100px"  runat="server" Text="Submit" CssClass="button"
                                                      OnClick="cmdAdd_Click" /&gt;
                                              &lt;/td&gt;
                                      &lt;/tr&gt;
                                  &lt;%--&lt;tr&gt;
                                     &lt;td style="text-align: right"&gt;
                                                  &lt;asp:Button ID="cmdSend" Width="100px"  runat="server" Text="Send" CssClass="button"
                                                      OnClick="cmdSend_Click" /&gt;
                                              &lt;/td&gt;
                                      &lt;/tr&gt;--%&gt;
                                       &lt;tr&gt;
                                              &lt;td style="text-align: right"&gt;
                                                  &lt;asp:Button ID="btnClear" Width="100px"   runat="server" Text="Clear" CssClass="button"
                                                      OnClick="btnClear_Click" /&gt;
                                              &lt;/td&gt;
                                         &lt;/tr&gt;
                                          &lt;tr&gt;
  
  
                                              &lt;td style="text-align: right"&gt;
                                                  &lt;asp:Button ID="btnCancel" Width="100px"  runat="server" Text="Cancel" CssClass="button"
                                                       OnClick="btnCancel_Click" /&gt;
                                              &lt;/td&gt;
                                  &lt;/tr&gt;
                              &lt;/table&gt;
                          &lt;/td&gt;
                      &lt;/tr&gt;
                  &lt;/table&gt;
              &lt;/div&gt;
      &lt;/div&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>c# code:-</p>
  
  <pre><code> private void ProcessFile(string filename, string filePath)
      {
          try
          {
              DataRow dr;
  
              string line;
  
              string content = "";
  
              dr = tblFileContent.NewRow();
  
              // Read the file and display it line by line.
              //using (StreamReader file = new StreamReader(@"C:\Upload.txt"))
              using (StreamReader file = new StreamReader(filePath))
              {
                  /*while ((line = file.ReadLine()) != null)
                  {
                      content = line + "\n";
  
                  }*/
  
                  txtContents.Text += filename+"\n";
  
  
                  file.Close();
              }
  
  
  
          }
  }
  </code></pre>