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. I'm making a bulletin board.

I'm making a bulletin board.

Scheduled Pinned Locked Moved ASP.NET
databasetutorialquestionworkspace
3 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.
  • L Offline
    L Offline
    lsh486love
    wrote on last edited by
    #1

    Hello. I finished a bullentin board with Repeater on my pages . I would like to make a seaching box(?) to show up a result on the list of Repeater, when someone searchs something by inputting on textbox. So, I put Dropdownlist, Textbox and imagebutton through tool box on the page. I mean I would like to make something like "Search" on top of this page. Search [ Text Box ] [Dropdownlist] [button] And I'm coding like the following code. protected void Select_Btn1_Click(object sender, ImageClickEventArgs e) { string title; title = Search_Txt1.Text; if (DropDownList1.SelectedValue== "Title") { SqlConnection cn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["aspnetdbConnectionString"].ConnectionString); string sql = "Select * From t_Pds where Title = '"+ Title +"' "; } } But I don't know how to show up the result on the list of Repeater.

    C A 2 Replies Last reply
    0
    • L lsh486love

      Hello. I finished a bullentin board with Repeater on my pages . I would like to make a seaching box(?) to show up a result on the list of Repeater, when someone searchs something by inputting on textbox. So, I put Dropdownlist, Textbox and imagebutton through tool box on the page. I mean I would like to make something like "Search" on top of this page. Search [ Text Box ] [Dropdownlist] [button] And I'm coding like the following code. protected void Select_Btn1_Click(object sender, ImageClickEventArgs e) { string title; title = Search_Txt1.Text; if (DropDownList1.SelectedValue== "Title") { SqlConnection cn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["aspnetdbConnectionString"].ConnectionString); string sql = "Select * From t_Pds where Title = '"+ Title +"' "; } } But I don't know how to show up the result on the list of Repeater.

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Well, you have bigger issues than that. The obvious solution to your immediate problem ( apart from the general poor coding style ), is to run your SQL and bind your repeater to the result. Your bigger issue, is that I can erase your bullitin board simply by typing in the right search term. Do some research on SQL injection attacks.

      Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

      1 Reply Last reply
      0
      • L lsh486love

        Hello. I finished a bullentin board with Repeater on my pages . I would like to make a seaching box(?) to show up a result on the list of Repeater, when someone searchs something by inputting on textbox. So, I put Dropdownlist, Textbox and imagebutton through tool box on the page. I mean I would like to make something like "Search" on top of this page. Search [ Text Box ] [Dropdownlist] [button] And I'm coding like the following code. protected void Select_Btn1_Click(object sender, ImageClickEventArgs e) { string title; title = Search_Txt1.Text; if (DropDownList1.SelectedValue== "Title") { SqlConnection cn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["aspnetdbConnectionString"].ConnectionString); string sql = "Select * From t_Pds where Title = '"+ Title +"' "; } } But I don't know how to show up the result on the list of Repeater.

        A Offline
        A Offline
        Abhishek Sur
        wrote on last edited by
        #3

        Hey, Just you can do like this :

        SqlConnection cn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["aspnetdbConnectionString"].ConnectionString);
        string sql = "Select * From t_Pds where Title = @p_search ";
        SqlCommand cmd = new SqlCommand(sql,cn);
        cmd.Parameters.add("@p_search",SqlDbType.VarChar,100);
        SqlDataAdapter sAdpt = new SqlDataAdapter(cmd);
        DataSet ds = new DataSet();
        sAdpt.Fill(ds, "t_Pds");

        Now you bind the sql to the Repeater:

        yourrepeater.DataSource = ds.Tables["t_Pds"];
        yourrepeater.DataBind();

        :rose:

        Abhishek Sur My Latest Articles Working with Excel using MDAC
        Basics on LINQ and Lambda Expressions
        Create .NET Templates

        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