brijesh prajapati

brijesh prajapati

  • NA
  • 158
  • 16.9k

in c# Dynamically Fill a Combox

Jan 7 2013 7:09 AM

public void FillLedgerType()

       {

           DataTable LedgerTypeDT = new DataTable();

 

           DataColumn LedgerType = new DataColumn("LedgerType", typeof(string));

           LedgerTypeDT.Columns.Add(LedgerType);

 

           DataColumn LedgerTypeID = new DataColumn("LedgerTypeID", typeof(string));

           LedgerTypeDT.Columns.Add(LedgerTypeID);

 

           DataRow row = null;

 

           row = LedgerTypeDT.NewRow();

           row["LedgerType"] = "--Select--";

           row["LedgerTypeID"] = "0";

           LedgerTypeDT.Rows.Add(row);

 

           row = LedgerTypeDT.NewRow();

           row["LedgerType"] = "Credit";

           row["LedgerTypeID"] = "1";

           LedgerTypeDT.Rows.Add(row);

           row = LedgerTypeDT.NewRow();

 

           row["LedgerType"] = "Debit";

           row["LedgerTypeID"] = "2";

           LedgerTypeDT.Rows.Add(row);

           row = LedgerTypeDT.NewRow();

 

 

           CmbAccountType.DataSource = LedgerTypeDT;

           CmbAccountType.DisplayMember = "LedgerType";

           CmbAccountType.ValueMember = "LedgerTypeID";

       }


Answers (2)