my code is like this
Expand|Select|Wrap|Line Numbers
- <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Report.aspx.cs" Inherits="SearchReport.Report" %>
- <!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>Report</title>
- </head>
- <body>
- <form id="form1" runat="server">
- <div>
- <table cellpadding="0" width="700" align="center" border="1">
- <tr>
- <td height="50"><img src="header.jpg" alt="header" width="700"/>
- </td>
- </tr>
- <tr>
- <td>
- Search:
- <asp:TextBox ID="txtreport" runat="server"></asp:TextBox>
- <asp:DataGrid ID="gridreport" runat="server" AutoGenerateColumns="false">
- <Columns>
- <asp:BoundColumn DataField="Name" HeaderText="Name" HeaderStyle-BackColor="Gray"></asp:BoundColumn>
- <asp:BoundColumn DataField="Path" HeaderText="Path" HeaderStyle-BackColor="gray"></asp:BoundColumn>
- <asp:BoundColumn DataField="Description" HeaderText="Description" HeaderStyle-BackColor="gray"></asp:BoundColumn>
- </Columns>
- </asp:DataGrid>
- </td>
- </tr>
- <tr>
- <td>
- <asp:Button ID="cmdbutton" align="center" Text="Search" runat="server" OnClick="cmdbutton_Click" />
- </td>
- </tr>
- </table>
- </div>
- </form>
- </body>
- </html>
- using System;
- using System.Data;
- using System.Configuration;
- using System.Collections;
- using System.Web;
- using System.Web.Security;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- using System.Web.UI.HtmlControls;
- using System.Data.SqlClient;
- using System.Data.SqlTypes;
- namespace SearchReport
- {
- public partial class Report : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- }
- protected void txtreport_TextChanged(object sender, EventArgs e)
- {
- }
- protected void cmdbutton_Click(object sender, EventArgs e)
- {
- SqlConnection oConn = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["oConn"]);
- SqlDataAdapter da = new SqlDataAdapter("dbo.win_ReportListSearch", oConn);
- da.SelectCommand.CommandType = CommandType.StoredProcedure;
- DataSet ds = new DataSet();
- da.SelectCommand.Parameters.Add(new SqlParameter("@Name",txtreport.Text));
- //if (txtreport.Text.ToString() != "")
- //{
- //da.SelectCommand.Parameters.Add(new SqlParameter("@Name", txtreport.Text));
- //}
- oConn.Open();
- da.SelectCommand.ExecuteNonQuery();
- oConn.Close();
- da.Fill(ds);
- this.gridreport.DataSource = ds;
- this.DataBind();
- da.Dispose();
- }
- }
- }
and the store procedure is like this
Expand|Select|Wrap|Line Numbers
- ALTER PROCEDURE [dbo].[win_ReportListSearch]
- @Name varchar(30)
- as
- SELECT [Name],
- [Path],
- [Description]
- FROM Catalog
- WHERE [Name] like (@name)
- please help me with this problem