a dropdown list and textbox (id =txtSearch) .My db table is book_details. where values are
c_id book_name author_name book_category
1 abc ASD Adventure
2 def zxc Horror
3 ghj qwe Education
in my drop down values are : author,bookname,category. i want to show the list in the text box like autocomplete function
if i choose author from drop down then in text box only author names should populate and show the list and if i choose category from dropdown then it musst show the book category list in the drop down
Kindly suggest me in this regard
selva kumarPosted Jul 2, 2013, 6:45 AM
if(ddl1.selecteditem.text=="Author")
{
Con.open();
sql command Cmd=new sqlcommand("select author_name from table name",Con);
sql data reader dr=Cmd.execute nonquery();
whilw(dr.read())
{
textbox1.text=dr["author_name"].tostring();
}
Con.close();
}
saif begPosted Jul 2, 2013, 2:25 AM
if i select "Author" from dropdownlist then all author name list should populate in the textbox.
and suppose if i press "a" then it must show the list of authors whose name starts with "a".
functionality like autocomplete textbox
selva kumarPosted Jul 2, 2013, 2:04 AM
write the code on dropdownlist selected index changed event.....
if(ddl1.selecteditem.text=="abc")
{
Con.open();
sql command Cmd=new sqlcommand("select author_name from table name",Con);
sql data reader dr=Cmd.execute nonquery();
whilw(dr.read())
{
textbox1.text=dr["author_name"].tostring();
}
Con.close();
}
Mark as "Answered" if its helpful..............