Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

How to insert a null value to combobox which is bind with datasource

$
0
0

Hi,

i am working on c# winforms application. I have 2 comboboxes one is CustomerCbBox and another is OrderCbBox. CustomerCbBox is bind with data source.

on CustomerCbBox SelectedIndexChanged event data is populated in OrderCbBox from data source. 

i want to add a null or empty field in CustomerCbBox. all I want is that when the user don't Select Customer Name and OrderNo null or empty data enter in database. but when i click Insert Button it generate error "Object reference is not "object reference not set to an instance of an object".

here is my code.

  private void MainForm_Load(object sender, EventArgs e)
            {

production pd = new production();

CustomerCbBox.DataSource = pd.Customer();

CustomerCbBox.DisplayMember = "Cust";

CustomerCbBox.ValueMember = "CustId";

}

 private void CustomerCbBox_SelectedIndexChanged(object sender, EventArgs e)
              {
                  try
                  {
                      string PartyName = CustomerCbBox.SelectedIndex.ToString();
                       PONum1.DataSource = pd.GetPOnumActive(PartyName1);
                          PONum1.DisplayMember = "PONum";
                          PONum1.ValueMember = "PONum";
                     
                  }
                  catch (Exception ex)
                  {
                      MessageBox.Show(ex.Message);
                  }
            }
     Please help me to solve this problem thanks.      



Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>