using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.Data.SqlClient; public partial class jv : System.Web.UI.Page { SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["NewCon"]); DataSet ds5 = new DataSet(); protected void Page_Load(object sender, EventArgs e) { Session["compid"] = 35; if (!Page.IsPostBack) { //fill debit account leger SqlDataAdapter da5 = new SqlDataAdapter("select [AC-SubAccounts].subaccountid, [AC-SubAccounts].subaccountname from [AC-AccountHeads] INNER JOIN [AC-SubAccounts] ON [AC-AccountHeads].AccountHeadID = [AC-SubAccounts].AccountHeadID AND [AC-AccountHeads].CompID = [AC-SubAccounts].CompID INNER JOIN [AC-AccountGroups] ON [AC-AccountGroups].AccountGroupID = [AC-AccountHeads].AccountGroupID AND [AC-AccountGroups].CompID = [AC-AccountHeads].CompID AND [AC-AccountGroups].AccountGroupName not in ('STOCK','PURCHASE ACCOUNT','SALES ACCOUNT','BANK ACCOUNTS') and [AC-SubAccounts].compid=" + Session["compid"] + " order by [ac-subaccounts].subaccountname", con); da5.Fill(ds5); cmbDebit.DataSource = ds5; cmbDebit.DataTextField = "subaccountname"; cmbDebit.DataValueField = "subaccountid"; cmbDebit.DataBind(); cmbDebit.Items.Insert(0, "Select a Ledger"); } } protected void Button1_Click(object sender, EventArgs e) { lstDebit.Items.Add(cmbDebit.SelectedItem.Text); } }