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