TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Sultan Mirza
NA
5
563
Fill description textbox on the basis of value selected in partnumber
Aug 20 2020 5:10 AM
I have 2 textboxes txtPartNum and txtDesc. partnumber is autocomplete from database
i have the partnumber and description saved in list _partNum. how do i get the description text box filled on the basis of partnumber selected on textChanged or keyDown event. code suggestion please.?
public
class
PartNumbers
{
public
string
parts {
get
;
set
; }
public
string
descr {
get
;
set
; }
}
List<PartNumbers> _partNum =
new
List<PartNumbers>();
public
void
partNumberLoad()
{
try
{
string
query =
"select itmPartNumber, itemDescr from vstItems"
;
SqlCommand cmd =
new
SqlCommand(query, MainClass.con);
if
(MainClass.con.State == ConnectionState.Closed)
MainClass.con.Open();
SqlDataReader sdr = cmd.ExecuteReader();
AutoCompleteStringCollection autoPart =
new
AutoCompleteStringCollection();
while
(sdr.Read())
{
autoPart.Add(sdr[
"itmPartNumber"
].ToString());
PartNumbers partNumbers =
new
PartNumbers { parts = sdr[
"itmPartNumber"
].ToString(), descr = sdr[
"itemDescr"
].ToString() };
_partNum.Add(partNumbers);
}
sdr.Close();
cmd.Connection.Close();
txtPartNum.AutoCompleteMode = AutoCompleteMode.Suggest;
txtPartNum.AutoCompleteSource = AutoCompleteSource.CustomSource;
txtPartNum.AutoCompleteCustomSource = autoPart;
}
}
Reply
Answers (
1
)
How to assign datatable value to a field in the list
Regarding connection error