using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Data.SqlClient; namespace DiscntdRtrvng { public partial class DiscntdRtrvng : Form { SqlConnection con = new SqlConnection("server=.;user id=sa;password=123;database=Seed_Employee"); SqlCommand cmd; DataSet ds; SqlDataAdapter da; string s; public DiscntdRtrvng() { InitializeComponent(); } private void DiscntdRtrvng_Load(object sender, EventArgs e) { s = "select EmpId from Employee"; da = new SqlDataAdapter(s, con); ds = new DataSet(); da.Fill(ds, "emp"); // DataRow row = ds.Tables[0].Rows[0]; cbxEid.DataSource = ds.Tables[0]; cbxEid.DisplayMember = "EmpId"; //dataGridView1.DataSource = ds.Tables[0]; } private void cbxEid_SelectedIndexChanged(object sender, EventArgs e) { s = "select * from Employee where EmpId=" + cbxEid.SelectedItem.ToString(); da = new SqlDataAdapter(s, con); ds = new DataSet(); da.Fill(ds, "emp"); dataGridView1.DataSource = ds.Tables[0]; } } }
cbxEid.SelectedItem.ToString();
cbxEid.SelectedItem.Text
cbxEid.SelectedItem.Value
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)