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
mansoor mansoor
NA
248
0
ComboBox Issue selectedIndexChanged
Apr 6 2020 3:24 AM
I have an Inventory Application with form of ProductMaster and I called Parent Category,Category and Sub Category to this form
All categories are saved in to one category table Named as tb_Category and each category and sub category saved as its own ID
I try to call the code like this
private void cmbMainCategory_SelectedIndexChanged(object sender, EventArgs e)
{
string conString = @"server=LAPTOP-UJIIOP3B; database=Inventory; uid=sa; password=praman1947;";
SqlConnection conn = new SqlConnection(conString);
DataSet ds = new DataSet();
try
{
conn.Open();
SqlCommand cmd = new SqlCommand("select CategoryCode,CategoryName,ID from tb_Category where Flag='C' AND ID= '" + comboBox1.SelectedValue+ "' ", conn);
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
da.Fill(ds);
cmbcategory.DisplayMember = "CategoryName";
cmbcategory.ValueMember = "CategoryCode";
cmbcategory.DataSource = ds.Tables[0];
}
catch (Exception ex)
{
//Exception Message
}
finally
{
conn.Close();
conn.Dispose();
}
}
The value coming to 'cmbcategory' but the problem is the proper value coming after to selection of 'cmbMainCategory' and while loading the form and Main category selection showing the result of first row Main Category
Reply
Answers (
1
)
C# email body displays as HTML
C# listview header name=value from database