Example #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         LinqDataSource1.DataBind();
         GridView1.DataBind();
     }
 }
Example #2
0
    // <Snippet1>
    protected void Add_Click(object sender, EventArgs e)
    {
        System.Collections.Specialized.ListDictionary listDictionary
            = new System.Collections.Specialized.ListDictionary();
        listDictionary.Add("ProductName", TextBox1.Text);
        listDictionary.Add("ProductCategory", "General");
        listDictionary.Add("Color", "Not assigned");
        listDictionary.Add("ListPrice", null);
        LinqDataSource1.Insert(listDictionary);

        TextBox1.Text = String.Empty;
        DetailsView1.DataBind();
    }
Example #3
0
    protected void submit_Click(object sender, EventArgs e)
    {
        ListDictionary customerRow = new ListDictionary();

        customerRow.Add("ContactName", firstname.Text + " " + lastname.Text);
        customerRow.Add("CustomerID", (firstname.Text.Substring(0, 3) + lastname.Text.Substring(0, 2)));
        customerRow.Add("CompanyName", company_name.Text);
        customerRow.Add("Phone", phone.Text);
        LinqDataSource1.Insert(customerRow);
        GridView1.DataBind();
        form1.Visible = false;
        form2.Visible = true;
        Label1.Text   = firstname.Text.Substring(0, 3) + lastname.Text.Substring(0, 2);
    }
Example #4
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        ListDictionary insertParameters = new ListDictionary();

        TextBox      name   = FormView1.FindControl("nameBox") as TextBox;
        TextBox      author = FormView1.FindControl("authorBox") as TextBox;
        DropDownList type   = FormView1.FindControl("DropDownMovieList") as DropDownList;

        //check if data exists already

        bool exists = false;

        for (int i = 0; i < GridView1.Rows.Count; i++)
        {
            String valueName = GridView1.Rows[i].Cells[1].Text.ToString();
            if ((valueName.Equals(name.Text)))
            {
                //record exists
                exists = true;
                //ShowPopUpMsg("Name already exists in the database. Please check details in 'name' field");

                break;
            }
            else
            {
                exists = false;
                //record not exists
            }
        }
        //insert if valid
        if (exists == false)
        {
            insertParameters.Add("Name", name.Text);
            insertParameters.Add("AuthorName", author.Text);
            insertParameters.Add("Type", type.SelectedItem.Text);
            insertParameters.Add("DateAdded", DateTime.Now.ToShortDateString());

            LinqDataSource1.Insert(insertParameters);

            GridView1.DataBind();
            insertParameters.Clear();
            messagePanel.Visible = true;
            messagePanel.Dispose();
        }
        else if (exists == true)
        {
            PanelWarning.Visible = true;
            PanelWarning.Dispose();
        }
    }
Example #5
0
        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Insert")
            {
                var tb = (TextBox)GridView1.FooterRow.FindControl("tbInsertName");


                LinqDataSource1.Insert(new Dictionary <string, string>()
                {
                    { "Name", tb.Text }
                });
                tb.Text = "";
                GridView1.DataBind();
            }
        }
Example #6
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            TextBox TextBox1 = (TextBox)GridView1.FooterRow.FindControl("TextBox1");
            TextBox TextBox2 = (TextBox)GridView1.FooterRow.FindControl("TextBox2");
            TextBox TextBox3 = (TextBox)GridView1.FooterRow.FindControl("TextBox3");

            System.Collections.Specialized.ListDictionary listDictionary = new System.Collections.Specialized.ListDictionary();
            listDictionary.Add("c_code", TextBox1.Text);
            listDictionary.Add("c_name", TextBox2.Text);
            listDictionary.Add("c_credit", TextBox3.Text);
            LinqDataSource1.Insert(listDictionary);

            TextBox1.Text = String.Empty;
            TextBox2.Text = String.Empty;
            TextBox3.Text = String.Empty;
            GridView1.DataBind();
        }
Example #7
0
    // <Snippet1>
    protected void Reset_Click(object sender, EventArgs e)
    {
        ListDictionary keyValues = new ListDictionary();
        ListDictionary newValues = new ListDictionary();
        ListDictionary oldValues = new ListDictionary();

        keyValues.Add("ProductID", int.Parse(((Label)DetailsView1.FindControl("IDLabel")).Text));

        oldValues.Add("ProductName", ((Label)DetailsView1.FindControl("NameLabel")).Text);
        oldValues.Add("ProductCategory", ((Label)DetailsView1.FindControl("CategoryLabel")).Text);
        oldValues.Add("Color", ((Label)DetailsView1.FindControl("ColorLabel")).Text);

        newValues.Add("ProductName", "New Product");
        newValues.Add("ProductCategory", "General");
        newValues.Add("Color", "Not assigned");

        LinqDataSource1.Update(keyValues, newValues, oldValues);

        DetailsView1.DataBind();
    }
        private void InitControlValuesForEdit(int lessonId)
        {
            train_lesson_basicInfo info = bEdit.select_info(lessonId);

            Name.Text           = info.Name;
            Name.Enabled        = true;
            Number.Text         = info.Number;
            Number.Enabled      = true;
            Time.Text           = info.Time.ToString();
            Time.Enabled        = true;
            Description.Text    = info.Description;
            Description.Enabled = true;

            Type.Value   = info.Type;
            Type.Enabled = true;
            Type.DataBind();

            LinqDataSource1.DataBind();
            btnSave.Enabled = true;
            //btnSubmit.Enabled = false;
            btnDelete.Enabled = true;
        }
Example #9
0
    protected void Button12_Click(object sender, EventArgs e)
    {
        if (TextBox1.Text.Length > 1)
        {
            LinqDataSource1.Where = "Name.Contains(" + "\"" + TextBox1.Text + "\"" + ")";
        }
        else if (TextBox2.Text.Length > 1)
        {
            LinqDataSource1.Where = "Melli_ID=" + "\"" + TextBox2.Text + "\"";
        }
        else
        {
            LinqDataSource1 = LinqDataSource2;
            LinqDataSource1.DataBind();
            Response.Redirect("MainPage3.aspx");
        }

        // gridvi.DataBind();


        //From u In db.vUser Where u.First_Name.Contains(searchText) Select u
    }
Example #10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int orderidd = 0;

        if (!IsPostBack)
        {
            foreach (var v in database.Orders)
            {
                if (v.OrderID > orderidd)
                {
                    orderidd = v.OrderID;
                }
            }
            DateTime now = new DateTime();
            now = DateTime.Now.Date;
            ListDictionary NWorderRow = new ListDictionary();
            NWorderRow.Add("CustomerID", (string)Session["UserID"]);
            NWorderRow.Add("OrderDate", now);
            NWorderRow.Add("OrderID", orderidd + 1);
            LinqDataSource1.Insert(NWorderRow);
            GridView1.DataBind();
            getData(orderidd + 1);
        }
    }
 protected void Button1_Click(object sender, EventArgs e)
 {
     LinqDataSource1.DataBind();
     ListView1.DataBind();
 }