Example #1
0
    //在資料FormView完成資料繫結後存取其內容資料
    protected void fvEmp_DataBound(object sender, EventArgs e)
    {
        if (fvEmp.CurrentMode == FormViewMode.ReadOnly)
        {
            //透過DataRowView來讀取資料欄位,這方法也適用於DetailsView
            DataRowView drView = (DataRowView)fvEmp.DataItem;
            txtMsg1.Text  = "<Font Color='Red'>這是DataRowView</Font><br/>";
            txtMsg1.Text += drView["EmployeeID"].ToString() + "<br/>";
            txtMsg1.Text += drView["LastName"].ToString() + "<br/>";
            txtMsg1.Text += drView["FirstName"].ToString() + "<br/>";
            txtMsg1.Text += drView["City"].ToString() + "<br/>";
            txtMsg1.Text += drView["Country"].ToString() + "<br/>";

            //透過尋找Label控制項的方式來達成
            FormViewRow Row = fvEmp.Row;
            txtMsg2.Text  = "<Font Color='Red'>這是FormViewRow</Font><br/>";
            txtMsg2.Text += ((Label)Row.FindControl("txtEmployeeID")).Text + "<br/>";
            txtMsg2.Text += ((Label)Row.FindControl("txtLastName")).Text + "<br/>";
            txtMsg2.Text += ((Label)Row.FindControl("txtFirstName")).Text + "<br/>";
            txtMsg2.Text += ((Label)Row.FindControl("txtCity")).Text + "<br/>";
            txtMsg2.Text += ((Label)Row.FindControl("txtCountry")).Text + "<br/>";
        }

        AddPagerIndex();                //加入Page索引
    }
Example #2
0
 protected void FormView1_ItemCommand(object sender, FormViewCommandEventArgs e)
 {
     if (e.CommandName == "Đặt món")
     {
         FormViewRow row = FormView1.Row;
         string      ma  = ((Label)row.FindControl("mamonanLabel1")).Text;
         //string ma = "M103";
         decimal      gia = Decimal.Parse(((Label)row.FindControl("giaLabel")).Text);
         string       ten = ((Label)row.FindControl("tenmonanLabel")).Text;
         ShoppingCart acart;
         if (Session["cart"] == null)    //neu chua co gio hang
         {
             acart = new ShoppingCart(); //tao gio hang moi
         }
         else
         {
             acart = (ShoppingCart)Session["cart"];
         }
         //them vao gio hang
         acart.InsertItem(ma, ten, gia, 1);
         //dat lai vao session
         Session["cart"] = acart;
         //chuyen den trang gio hang
         Response.Redirect("Cart.aspx");
     }
 }
Example #3
0
        protected void fv_OfficerPosition_ItemInserting(object sender, FormViewInsertEventArgs e)
        {
            FormViewRow row = ((FormView)sender).Row;
            // UrlControl has limited separation of concerns and allows many variations to come out of the Url property
            // in this case, we have specified that the there has to be a file chosen from the DNN system.
            // UrlControl will use the FileID={fileid} output.  We are only interested in the actual file id.

            UrlControl urlOfficeBadge = row.FindControl("urlOfficeBadge") as UrlControl;

            if (urlOfficeBadge != null)
            {
                if (urlOfficeBadge.Url.StartsWith("FileID="))
                {
                    int fileid;
                    if (int.TryParse(urlOfficeBadge.Url.Substring(7), out fileid))
                    {
                        e.Values["FileId"] = fileid;
                    }
                }
                else if (urlOfficeBadge.Url.Equals(String.Empty))
                {
                    e.Values["FileId"] = null;
                }
            }
        }
Example #4
0
        protected void formViewLang_ItemCreated(object sender, EventArgs e)
        {
            LocaleController            lc  = new LocaleController();
            Dictionary <string, Locale> loc = lc.GetLocales(PortalSettings.Current.PortalId);

            FormViewRow row = formViewLang.HeaderRow;

            if (row != null)
            {
                PlaceHolder phLanguage = row.FindControl("phLanguage") as PlaceHolder;
                int         i          = 0;
                foreach (KeyValuePair <string, Locale> item in loc)
                {
                    HtmlGenericControl div = new HtmlGenericControl("div");
                    div.Style.Add("display", "table-cell");

                    ImageButton imgBtn = new ImageButton();
                    imgBtn.ID       = "imgLanguage" + i.ToString();
                    imgBtn.Click   += Language_Selected;
                    imgBtn.ImageUrl = "~\\images\\Flags\\" + item.Key + ".gif";
                    imgBtn.Style.Add("padding", "3px 10px 5px 10px");

                    imgBtn.Style.Add("border-width", "1px");
                    imgBtn.Style.Add("border-color", "#000000");

                    if (i == formViewLang.PageIndex)
                    {
                        imgBtn.Style.Add("border-style", "solid solid hidden solid");
                        imgBtn.Style.Add("margin", "0 0 1px 0;");
                        imgBtn.Style.Add("background-color", "White");
                    }
                    else
                    {
                        imgBtn.Style.Add("border-style", "solid solid solid solid");
                        imgBtn.Style.Add("margin", "0");
                        imgBtn.Style.Add("background-color", "LightGrey");
                    }
                    div.Controls.Add(imgBtn);
                    phLanguage.Controls.Add(div);
                    i++;
                }
            }
        }