Click here to Skip to main content
15,887,888 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
sir,

I have a textbox, i want...if user enter name then it should be auto complete if that name stored in sql server(database).

Thanking you!!

i am using this way in web based project this show an error message like......namespace name not found.........
C#
protected void txt_name_TextChanged(object sender, EventArgs e)
    {
        string autoC = "select vendername from tbl_vendermaster";
        SqlDataAdapter dtAuto = new SqlDataAdapter(autoC, con).Fill(dtAuto);
        GetAutoSourceCollectionFromTable(dtAuto);

    }
    private AutoCompleteStringCollection GetAutoSourceCollectionFromTable(DataTable table)
    {
        AutoCompleteStringCollection autoSourceCollection = new AutoCompleteStringCollection();

        foreach (DataRow row in table.Rows)
        {
            autoSourceCollection.Add(row[0]); //assuming required data is in first column
        }

        return autoSourceCollection;
    }
Posted
Updated 16-Feb-12 1:55am
v3
Comments
Anuja Pawar Indore 16-Feb-12 8:08am    
Removed extra pre tag

read this

http://stackoverflow.com/questions/3349374/is-it-possible-to-make-a-datatable-as-a-autocompletesource-in-a-textbox-c[^]

Hope this helps if yes then accept and vote the answer
--Rahul D.
 
Share this answer
 
Comments
rajesh@1989 16-Feb-12 6:01am    
thanx sir,
but hint me in detail how can this methods is called when we enter in textbox....
RDBurmon 16-Feb-12 6:25am    
No no no , No need to call this method since it is autocomplete source property of C# textbox control. It will take care of this .
rajesh@1989 16-Feb-12 6:39am    
pls sir,
read again this problem. i am improved this question.......
sir this is a web based project so namespace could not been found.....
thanking you
I could solve with this function


public void ExtractArchive(string zipFilename, string ExtractDir)
{
int Redo = 1;
ZipInputStream MyZipInputStream = default(ZipInputStream);
FileStream MyFileStream = default(FileStream);
MyZipInputStream = new ZipInputStream(new FileStream(zipFilename, FileMode.Open, FileAccess.Read));
ZipEntry MyZipEntry = MyZipInputStream.GetNextEntry();
Directory.CreateDirectory(ExtractDir);
while ((MyZipEntry != null))
{
if ((MyZipEntry.IsDirectory))
{
Directory.CreateDirectory(ExtractDir + "\\" + MyZipEntry.Name);
}
else
{
if (!Directory.Exists(ExtractDir + "\\" + Path.GetDirectoryName(MyZipEntry.Name)))
{
Directory.CreateDirectory(ExtractDir + "\\" + Path.GetDirectoryName(MyZipEntry.Name));
}
MyFileStream = new FileStream(ExtractDir + "\\" + MyZipEntry.Name, FileMode.OpenOrCreate, FileAccess.Write);
int count = 0;
byte[] buffer = new byte[4097];
count = MyZipInputStream.Read(buffer, 0, 4096);
while (count > 0)
{
MyFileStream.Write(buffer, 0, count);
count = MyZipInputStream.Read(buffer, 0, 4096);
}
MyFileStream.Close();
}
try
{
MyZipEntry = MyZipInputStream.GetNextEntry();
}
catch (Exception ex)
{
MyZipEntry = null;
}
}
if ((MyZipInputStream != null))
MyZipInputStream.Close();
if ((MyFileStream != null))
MyFileStream.Close();
}
 
Share this answer
 
Hi, use javascript and ajax for this, and call js function onkeyup event.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900