Last post Apr 24, 2014 09:41 PM by Kevin Shen - MSFT
Apr 24, 2014 07:15 AM|Abhi_soni|LINK
i have a repeater control i want to search Repeaters record (wild card search) usng text box
Apr 24, 2014 09:41 PM|Kevin Shen - MSFT|LINK
Based on my understanding about your post,when you type a string in text and click a search button,you need to search the result from the database.
So i suggest you add a button and a textbox like below :
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:Button ID="button1" runat="server" OnClick="button1_Click"/>
when you click the button ,you can search your result(wild card search) ,like below:
protected void button1_Click(object sender, EventArgs e)
//Here you can use LIKE for wild card search
string sql = "select * from Cus where name like '%"+name+"%'";
string connstring = "Data Source=xx;Initial Catalog=xx;User Id=sa;Password=xx;";
SqlConnection conn = new SqlConnection(connstring);
SqlCommand cmd = new SqlCommand(sql, conn); // Bind your repeater agagin for searching result.
myRepeater.DataSource = cmd.ExecuteReader();
Hope it can help you.