Example #1
0
        private void PopulateData()
        {
            CustomerDataaccess dataAccess = new CustomerDataaccess();
            var list = dataAccess.GetCustomers();

            dataLikst1.DataSource = list;
            dataLikst1.DataBind();
        }
Example #2
0
        //string connectionString = "server=VINDHYA\\SQLDEV2016;Integrated Security=True;Initial Catalog=Northwind";
        //string sql = "SELECT CustomerId,CompanyName,ContactName,City,Country from Customers";
        //DataSet ds;
        //SqlDataAdapter adapter;
        //string tableName = "Customers";


        private void PopulateData()
        {
            //if (adapter == null)
            //    adapter = new SqlDataAdapter(sql, connectionString);
            //if (ds == null) ds = new DataSet();
            //adapter.Fill(ds, tableName);
            //this.repeater2.DataSource = ds;
            //repeater2.DataMember = tableName;
            //repeater2.DataBind();
            CustomerDataaccess dataaccess = new CustomerDataaccess();
            var list = dataaccess.GetCustomers();

            repeater2.DataSource = list;
            repeater2.DataBind();
        }
Example #3
0
        protected void dataLikst1_UpdateCommand(object source, DataListCommandEventArgs e)
        {
            string custId  = dataLikst1.DataKeys[e.Item.ItemIndex].ToString();
            string Company = ((TextBox)e.Item.FindControl("txtCompany")).Text;

            Response.Write("Compant:" + Company);
            dataLikst1.EditItemIndex = -1;
            PopulateData();

            string Contact = ((TextBox)e.Item.FindControl("txtContact")).Text;
            //Response.Write("Contact:" + Contact);


            string city = ((TextBox)e.Item.FindControl("txtCity")).Text;
            //Response.Write("City:" + city);


            string country = ((TextBox)e.Item.FindControl("txtCountry")).Text;

            Response.Write("Country:" + country);

            Customer obj = new Customer
            {
                CustomerId  = custId,
                CompanyName = Company,
                ContactName = Contact,
                City        = city,
                Country     = country
            };

            try
            {
                CustomerDataaccess dataAccess = new CustomerDataaccess();
                dataAccess.UpdateCustomer(obj);
            }catch (Exception ex)
            {
                throw ex;
            }
        }