Click here to Skip to main content
Sign Up to vote bad
good
See more: C#DataBinding
I have the a class in my application. It has been bound to winform textbox controls. But the textbox which is bound to BookingNo property, always shows zero (0). But i want the textbox keep empty. Is there any way to do it? Here is my code snippet.
 
public class Booking 
    {
    private int pBookingNo;
    private string pCustomerName;
    private string pAddress;
 
    public int BookingNo
    {
        get { return pBookingNo; }
        set
        {
            if (!value.Equals(pBookingNo))
            {
                pBookingNo = value;
            }
        }
    }
 
    public string CustomerName
    {
        get { return pCustomerName; }
        set
        {
            if (!value.Equals(pCustomerName))
            {
                pCustomerName = value;
 
            }
        }
    }
 
    public Booking() { }
}
 

    public partial class Form1 : Form
    {
    public Form1()
    {
        InitializeComponent();
    }
 
    private void Form1_Load(object sender, EventArgs e)
    {
        AddDataBindings();
    }
 
    private void AddDataBindings()
    {
        bsBooking.DataSource = typeof(Booking);
 
        txtBookingNo.DataBindings.Add("Text", bsBooking, "BookingNo", true, DataSourceUpdateMode.OnPropertyChanged, null, "G", GlobalVariables.CurrentCultureInfo);
        txtCustomerName.DataBindings.Add("Text", bsBooking, "CustomerName");
 
    }
}
Posted 5 Oct '12 - 4:00


1 solution

I got the solution-
 
public int? BookingNo { get; set; }
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 OriginalGriff 335
1 Sergey Alexandrovich Kryukov 318
2 Arun Vasu 315
3 Maciej Los 208
4 Aarti Meswania 180
0 Sergey Alexandrovich Kryukov 9,680
1 OriginalGriff 7,539
2 CPallini 4,018
3 Rohan Leuva 3,362
4 Maciej Los 2,951


Advertise | Privacy | Mobile
Web04 | 2.6.130523.1 | Last Updated 5 Oct 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid