예제 #1
0
/// <summary>
    /// This is the event that will be raised when the binding to the checkbox button happens.
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    void CheckBox_DataBinding(object sender, EventArgs e)
    {
        GraphicalCheckBox txtdata   = (GraphicalCheckBox)sender;
        GridViewRow       container = (GridViewRow)txtdata.NamingContainer;

        if (DataBinder.Eval(container.DataItem, _columnName.Replace("`", "")) != DBNull.Value)
        {
            txtdata.EnableViewState = false;
            txtdata.ID = "Check" + DataBinder.Eval(container.DataItem, _columnName.Replace("`", "")).ToString();
        }
    }
예제 #2
0
    void ITemplate.InstantiateIn(System.Web.UI.Control container)
    {
        switch (_templateType)
        {
        case "TextAreaItem":
            Label tb1 = new Label();                                                //Allocates the new text box object.
            tb1.DataBinding += new EventHandler(tb1_DataBinding);                   //Attaches the data binding event.
            container.Controls.Add(tb1);                                            //Adds the newly created textbox to the container.
            break;

        case "OrderItem":
            ImageButton orderBtnUp = new ImageButton();
            orderBtnUp.ImageUrl     = "images/up.gif";
            orderBtnUp.DataBinding += new EventHandler(orderBtnUp_DataBinding);
            container.Controls.Add(orderBtnUp);

            ImageButton orderBtnDn = new ImageButton();
            orderBtnDn.ImageUrl     = "images/dn.gif";
            orderBtnDn.DataBinding += new EventHandler(orderBtnDn_DataBinding);
            container.Controls.Add(orderBtnDn);
            Label OrderNum = new Label();
            OrderNum.DataBinding += new EventHandler(orderNum_DataBinding);
            break;

        case "ShowItem":
            Literal showShowItem = new Literal();
            showShowItem.ID = "ShowLiteral";
            container.Controls.Add(showShowItem);
            break;

        case "DelItem":
            LinkButton DelBtn = new LinkButton();
            if (customField != "")
            {
                DelBtn.Text = "<img src=\"" + customField + "\" style=\"border:none;\">";
            }
            else
            {
                DelBtn.Text = "<img src=\"images/DelOn.png\" style=\"border:none;\" alt=\"" + Languages2.MyText("general_Delete") + "\" title=\"" + Languages2.MyText("general_Delete") + "\" >";
            }
            DelBtn.DataBinding += new EventHandler(DelBtn_DataBinding);
            container.Controls.Add(DelBtn);
            break;


        case "EditItem":
            HyperLink EditBtn = new HyperLink();
            EditBtn.CssClass = "EditUserFancyClass";
            if (_title != "")
            {
            }
            else
            {
                _title = Languages2.MyText("general_Edit");
            }
            EditBtn.Text         = "<img src=\"images/EditOff.png\" style=\"border:none; margin-right:10px;\" onmouseover=\"$(this).parent().parent().prev().children('.hideshowdivclass').show();this.src='images/EditOn.png'\" onmouseout=\"$(this).parent().parent().prev().children('.hideshowdivclass').hide();this.src='images/EditOff.png'\" alt=\"" + Languages2.MyText("general_Edit") + "\" title=\"" + _title + "\">";
            EditBtn.DataBinding += new EventHandler(EditBtn_DataBinding);
            ((TableCell)container).Style["width"] = "30px";
            container.Controls.Add(EditBtn);
            break;


        case "CheckBox":
            GraphicalCheckBox CheckBox   = new GraphicalCheckBox();
            Panel             checkPanel = new Panel();
            if (replaceField != "")
            {
                CheckBox.CheckedImg = replaceField;
            }
            else
            {
                CheckBox.CheckedImg = "images/SelectOn.png";
            }
            CheckBox.UncheckedImg = "images/SelectOff.png";
            CheckBox.Font.Size    = FontUnit.Parse("100%");
            CheckBox.Title        = Languages2.MyText("general_Select");
            CheckBox.DataBinding += new EventHandler(CheckBox_DataBinding);

            checkPanel.PreRender += checkPanel_PreRender;
            checkPanel.Controls.Add(CheckBox);
            container.Controls.Add(checkPanel);
            break;

        case "CheckFooter":
            Label  CheckAllLbl = new Label();
            string CheckImg    = "images/SelectOn.png";
            if (replaceField != "")
            {
                CheckImg = replaceField;
            }

            CheckAllLbl.Text = "<img src=\"" + CheckImg + "\" style=\"vertical-align:middle\" alt=\"" + Languages2.MyText("general_Select All") + "\" onclick=\"javascript:checkAll()\"> " + Languages2.MyText("general_Select All") + "";
            container.Controls.Add(CheckAllLbl);

            Label unCheckAllLbl = new Label();
            unCheckAllLbl.Text = "&nbsp;<img src=\"images/SelectOff.png\" style=\"vertical-align:middle\" alt=\"" + Languages2.MyText("general_Clear All") + "\" onclick=\"javascript:uncheckAll()\"> " + Languages2.MyText("general_Clear All") + "";
            container.Controls.Add(unCheckAllLbl);
            break;


        case "Header":
            LinkButton HeaderBtn = new LinkButton();

            TextBox WidthHid = new TextBox();
            WidthHid.CssClass         = "tableHid tableHid" + customField.Replace("`", "");
            WidthHid.Style["display"] = "none";
            container.Controls.Add(WidthHid);


            HeaderBtn.Font.Underline  = false;
            HeaderBtn.ForeColor       = System.Drawing.Color.White;
            HeaderBtn.CommandArgument = customField;
            HeaderBtn.Command        += HeaderBtn_Click;
            HeaderBtn.Text            = "&nbsp;&nbsp;" + _columnName + "&nbsp;&nbsp;";

            ((TableCell)container).CssClass = "resizeable cell" + customField.Replace("`", "");
            HeaderBtn.CssClass          = "cellLbl cellLbl" + customField.Replace("`", "").Trim();
            HeaderBtn.Style["display"]  = "block";
            HeaderBtn.Style["overflow"] = "hidden";

            container.Controls.Add(HeaderBtn);
            break;
        }
    }