Пример #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                #region 实始化控件

                joindateStart.SelectedDate = DateTime.Now.AddDays(-30);

                joindateEnd.SelectedDate = DateTime.Now;

                //UserGroup.AddTableData("SELECT [groupid], [grouptitle] FROM [" + BaseConfigs.GetTablePrefix + "usergroups] ORDER BY [groupid]");
                UserGroup.AddTableData(DatabaseProvider.GetInstance().GetGroupInfo());

                if ((DNTRequest.GetString("username") != null) && (DNTRequest.GetString("username") != ""))
                {
                    ViewState["condition"] = DatabaseProvider.GetInstance().Global_UserGrid_GetCondition(DNTRequest.GetString("username"));
                    //" [" + BaseConfigs.GetTablePrefix + "users].[username]='" + DNTRequest.GetString("username") + "' "
                    searchtable.Visible      = false;
                    ResetSearchTable.Visible = true;
                }

                if (ViewState["condition"] != null)
                {
                    searchtable.Visible      = false;
                    ResetSearchTable.Visible = true;
                }
                else
                {
                    if (DNTRequest.GetString("condition") != "")
                    {
                        ViewState["condition"]   = DNTRequest.GetString("condition").Replace("~^", "'").Replace("~$", "%");
                        searchtable.Visible      = false;
                        ResetSearchTable.Visible = true;
                    }
                }
                BindData();

                #endregion
            }
        }
Пример #2
0
        /// <summary>
        /// 数据列表项绑定事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void DataGrid_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                e.Item.Attributes.Add("onmouseover", "this.className='mouseoverstyle'");
                e.Item.Attributes.Add("onmouseout", "this.className='mouseoutstyle'");
                e.Item.Style["cursor"] = "hand";
                //e.Item.Cells[3].Attributes.Add("onclick", "alert('你点击的ID是: " + e.Item.Cells[0].Text + "!');");
            }

            if (!this.SaveDSViewState)
            {
                this.Controls[0].EnableViewState = false;
            }

            if (this.IsFixConlumnControls)
            {
                if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
                {
                    //int count=0;
                    for (int i = 0; i < e.Item.Cells.Count; i++)
                    {
                        if ((!e.Item.Cells[i].HasControls()))
                        {
                            if (GetBoundColumnFieldReadOnly()[i].ToString().ToLower() == "false") //判断是否存在只读属性
                            {
                                System.Web.UI.WebControls.TextBox t = new System.Web.UI.WebControls.TextBox();
                                t.ID = GetBoundColumnField()[i].ToString();
                                t.Attributes.Add("onmouseover", "if(this.className != 'FormFocus') this.className='FormBase'");
                                t.Attributes.Add("onmouseout", "if(this.className != 'FormFocus') this.className='formnoborder'");
                                t.Attributes.Add("onfocus", "this.className='FormFocus';");
                                t.Attributes.Add("onblur", "this.className='formnoborder';");
                                t.Attributes.Add("class", "formnoborder");
                                t.Text = e.Item.Cells[i].Text.Trim().Replace("&nbsp;", "");

                                //设置宽度
                                if (this.Columns[i].ItemStyle.Width.Value > 0)
                                {
                                    t.Width = (int)this.Columns[i].ItemStyle.Width.Value;
                                }
                                else
                                {
                                    t.Width = 100;
                                }
                                e.Item.Cells[i].Controls.Add(t);
                            }
                        }
                        else
                        {
                            foreach (System.Web.UI.Control c in e.Item.Cells[i].Controls)
                            {
                                //加载discuz下拉控件
                                if (c is Discuz.Control.DropDownList)
                                {
                                    Discuz.Control.DropDownList __dropdownlist = (Discuz.Control.DropDownList)c;
                                    if (__dropdownlist.SqlText != "")
                                    {
                                        __dropdownlist.AddTableData(__dropdownlist.SqlText);
                                    }

                                    try
                                    {
                                        __dropdownlist.SelectedValue = Convert.ToString(DataBinder.Eval(e.Item.DataItem, __dropdownlist.DataValueField));
                                    }
                                    catch
                                    {; }
                                }

                                //加载普通下拉控件
                                if (c is System.Web.UI.WebControls.DropDownList)
                                {
                                    System.Web.UI.WebControls.DropDownList __dropdownlist = (System.Web.UI.WebControls.DropDownList)c;
                                    try
                                    {
                                        __dropdownlist.SelectedValue = Convert.ToString(DataBinder.Eval(e.Item.DataItem, __dropdownlist.DataValueField));
                                    }
                                    catch
                                    {; }
                                }
                            }
                        }

                        // count++;
                    }
                }
            }
            else
            {
                if (e.Item.ItemType == ListItemType.EditItem)
                {
                    for (int i = 0; i < e.Item.Cells.Count; i++)
                    {
                        e.Item.Cells[i].BorderWidth = 1;
                        e.Item.Cells[i].BorderStyle = BorderStyle.Solid;
                        e.Item.Cells[i].BorderColor = System.Drawing.Color.FromArgb(234, 233, 225);
                        if (e.Item.Cells[i].HasControls())
                        {
                            for (int j = 0; j < e.Item.Cells[i].Controls.Count; j++)
                            {
                                System.Web.UI.WebControls.TextBox t = e.Item.Cells[i].Controls[j] as System.Web.UI.WebControls.TextBox;
                                if (t != null)
                                {
                                    t.Attributes.Add("onfocus", "this.className='FormFocus';");
                                    t.Attributes.Add("onblur", "this.className='FormBase';");
                                    t.Attributes.Add("class", "FormBase");
                                }
                            }
                        }
                    }
                }
            }
        }