using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.IO; using System.Data; using System.Diagnostics; using System.Drawing; public partial class Default3 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { Label4.Text = "Enter Search String"; Label4.Visible = true; TextBox1.Visible = true; } protected void ImageButton2_Click(object sender, ImageClickEventArgs e) { } protected void ImageButton3_Click(object sender, ImageClickEventArgs e) { } protected void TextBox1_TextChanged(object sender, EventArgs e) { char t = '\u0009'; string[] lines = System.IO.File.ReadAllLines(@"C:\ri.txt"); DataTable dt = new DataTable(); dt.Columns.Add("Item", typeof(System.String)); dt.Columns.Add("Title", typeof(System.String)); dt.Columns.Add("LastName", typeof(System.String)); dt.Columns.Add("FirstName", typeof(System.String)); DataRow dr = null; int found; foreach (string line in lines) { string[] words = line.Split(new Char[] { t }); found=0; found = words[2].IndexOf(TextBox1.Text); if (found > 0 ) { dr = dt.NewRow(); dr[0] = words[0]; dr[1] = words[2]; dr[2] = words[3]; dr[3] = words[4]; dt.Rows.Add(dr); } } GridView1.DataSource = dt; GridView1.DataBind(); } }
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> </div> <asp:ImageButton ID="ImageButton1" runat="server" onclick="ImageButton1_Click" style="z-index: 1; left: 115px; top: 34px; position: absolute" /> <asp:Label ID="Label2" runat="server" style="z-index: 1; left: 213px; top: 34px; position: absolute; width: 184px; height: 28px;" Text="Search by tittle"></asp:Label> <asp:ImageButton ID="ImageButton2" runat="server" onclick="ImageButton2_Click" style="z-index: 1; left: 445px; top: 34px; position: absolute" /> <asp:Label ID="Label3" runat="server" style="z-index: 1; left: 586px; top: 34px; position: absolute" Text="Search By Subject"></asp:Label> <asp:ImageButton ID="ImageButton3" runat="server" onclick="ImageButton3_Click" style="z-index: 1; left: 723px; top: 34px; position: absolute" /> <asp:GridView ID="GridView1" runat="server" style="z-index: 1; left: 31px; top: 158px; position: absolute; height: 256px; width: 685px"> </asp:GridView> <p> <asp:Label ID="Label1" runat="server" Text="Search by item" style="z-index: 1; left: 10px; top: 39px; position: absolute"></asp:Label> </p> <asp:TextBox ID="TextBox1" runat="server" ontextchanged="TextBox1_TextChanged" style="z-index: 1; left: 122px; top: 67px; position: absolute" Visible="False"></asp:TextBox> <asp:Label ID="Label4" runat="server" style="z-index: 1; left: 10px; top: 79px; position: absolute" Text="Enter Search" Visible="False"></asp:Label> </form> </body> </html>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)