Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Search specific Column of a database

Search specific Column of a database

Scheduled Pinned Locked Moved ASP.NET
learningdatabase
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    shravan28
    wrote on last edited by
    #1

    I want to add a search box on my Site that searches in the from specific column of a database.. Suppose the table consists of columns NAME OF BOOK,PUBLISHER,CATEGORY,FORMAT. it should be like this searchbox (User Input) dropdownlist(to search in specific column) 1)Name of book 2)Publisher 3)category resulting gridview control must contain the results with all the columns iam a beginner...

    N I 2 Replies Last reply
    0
    • S shravan28

      I want to add a search box on my Site that searches in the from specific column of a database.. Suppose the table consists of columns NAME OF BOOK,PUBLISHER,CATEGORY,FORMAT. it should be like this searchbox (User Input) dropdownlist(to search in specific column) 1)Name of book 2)Publisher 3)category resulting gridview control must contain the results with all the columns iam a beginner...

      N Offline
      N Offline
      Naveed Kamboh
      wrote on last edited by
      #2

      if you are using DataSet to fill the GridView thant call your DataSet in DataView class and your filter property to filter the data. if you are using ObjectDatasource then you can define filterexpression of object data source. I havn't used SqlDatasource you need to study ..

      Naveed Kamboh

      S 1 Reply Last reply
      0
      • N Naveed Kamboh

        if you are using DataSet to fill the GridView thant call your DataSet in DataView class and your filter property to filter the data. if you are using ObjectDatasource then you can define filterexpression of object data source. I havn't used SqlDatasource you need to study ..

        Naveed Kamboh

        S Offline
        S Offline
        shravan28
        wrote on last edited by
        #3

        please explain a bit..iam a beginner

        N 1 Reply Last reply
        0
        • S shravan28

          please explain a bit..iam a beginner

          N Offline
          N Offline
          Naveed Kamboh
          wrote on last edited by
          #4

          If you are beginner then please Read and make sample programs go to ASP.Net and watch some videos.

          Naveed Kamboh

          1 Reply Last reply
          0
          • S shravan28

            I want to add a search box on my Site that searches in the from specific column of a database.. Suppose the table consists of columns NAME OF BOOK,PUBLISHER,CATEGORY,FORMAT. it should be like this searchbox (User Input) dropdownlist(to search in specific column) 1)Name of book 2)Publisher 3)category resulting gridview control must contain the results with all the columns iam a beginner...

            I Offline
            I Offline
            IamMohan
            wrote on last edited by
            #5

            Hi, Follow the steps below:
            Create a following stored Procedure in SQL Server 2000/2005. Give the table name(In the Procedure) you want to query CREATE PROCEDURE [dbo].[TEST_PARAM] @Param varchar(100) AS BEGIN declare @dynamicQuery NVARCHAR(4000) set @dynamicQuery = 'Select ' + @Param + ' from TABLE_NAME ' exec sp_executesql @dynamicQuery END 2> This above store procedure will return all the values in the column you passed as a parameter. 3> On the server click of the Search button call this stored procedure by passing the columnName as in the table as a parameter and fill the values returned by the stored procedure in a DataSet ds. 4> Any have you know the columnName the user selected, use the same name in the select filter, like: GridView1.DataSource = ds.Tables[0].DefaultView.RowFilter = "ColumName = '" + txtSearchBox.Text.Trim()+ "'"; 5> Then the the grid View will be binded with the needed values. Thatz it. :-O

            M-o-h-a-n

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups