Very Urgent Help Needed
Hi!
I am new to ASP.NET and is using to make an application with C# as scripting Language.
I have query that:
I have one RadioButtonList Control with two Items and when user checks the one then the search will be done according to the selected option.
Now i have one text box and a List Box.When user clicks for say Manufacturer Name option of Radio..., and enters some text in Text Box and then clicks search Button, then List Box must get updated with all the Manufacturer Names containing the entire Text written in Text Box.
PROBLEM: i am facing is that when I enter the Text in Text Box and and click search button, list box doesnt get populated but when i change the select query with specific alphabet it works fine but i want the other way round.PLEASE HELP ASAP !
A code snippet is:
<%@ Page Language="C#" autoeventwireup="True" Debug="true" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.OleDb" %>
<script runat="server">
void Search_Click(object Source, EventArgs e)
{
if (RadioButtonList1.SelectedIndex == 0)
{
string val = TextBox1.Text;
string connectionstring;
string queryString;
DataSet Data = new DataSet();
OleDbConnection dbconnection;
OleDbDataAdapter dataAdapter;
connectionstring = "Provider=Microsoft.Jet.OLeDb.4.0;DATA SOURCE=" +
Server.MapPath("\\Database\\New_Tool.mdb") ;
queryString = "SELECT Company_Name FROM CompanyName WHERE Company_Name LIKE '@' + val +'@' ";
dbconnection = new OleDbConnection(connectionstring);
dbconnection.Open();
dataAdapter = new OleDbDataAdapter(queryString, dbconnection);
dataAdapter.Fill(Data,"Company_Name");
ListBox1.DataSource = Data;
ListBox1.DataTextField = "Company_Name";
ListBox1.DataValueField = "Company_Name";
ListBox1.DataBind();
}
}
Vinay Chugh
If I rest, I will rust ! Let's share the knowledge !
|