private void lkbDelectCheck_Click(object sender, System.EventArgs e) { string text = ""; ManagerHelper.CheckPrivilege(Privilege.DeleteMember); foreach (System.Web.UI.WebControls.GridViewRow gridViewRow in this.grdMemberList.Rows) { System.Web.UI.WebControls.CheckBox checkBox = (System.Web.UI.WebControls.CheckBox)gridViewRow.FindControl("checkboxCol"); if (checkBox.Checked) { text = text + this.grdMemberList.DataKeys[gridViewRow.RowIndex].Value.ToString() + ","; } } text = text.TrimEnd(new char[] { ',' }); if (string.IsNullOrEmpty(text)) { this.ShowMsg("请先选择要删除的会员账号!", false); return; } if (VShopHelper.IsExistUsers(text) > 0) { this.ShowMsg("选中会员中有分销商,请取消分销商资质后再删除!", false); return; } if (MemberHelper.Deletes(text)) { this.ShowMsg("成功删除了选择的会员!", true); this.BindData(); } }
private void BatchCreatDist_click(object sender, System.EventArgs e) { string text = ""; foreach (System.Web.UI.WebControls.GridViewRow gridViewRow in this.grdMemberList.Rows) { System.Web.UI.WebControls.CheckBox checkBox = (System.Web.UI.WebControls.CheckBox)gridViewRow.FindControl("checkboxCol"); if (checkBox.Checked) { text = text + this.grdMemberList.DataKeys[gridViewRow.RowIndex].Value.ToString() + ","; } } text = text.TrimEnd(new char[] { ',' }); if (string.IsNullOrEmpty(text)) { this.ShowMsg("请先选择要设置成分销商的会员账号!", false); return; } string msg = ""; if (MemberHelper.CreateDistributorByUserIds(text, ref msg)) { this.ShowMsg(msg, true); this.BindData(); return; } this.ShowMsg(msg, false); }
public GridHelper(UltraWebGrid grid, System.Web.UI.WebControls.CheckBox chbSelectAll) { this._grid = grid; this._chbSelectAll = chbSelectAll; this.InitGridHelper(); }
public static void DefaultButton(System.Web.UI.Page Page, ref System.Web.UI.WebControls.CheckBox checkBox, ref System.Web.UI.HtmlControls.HtmlInputButton inputButton) { try { System.Text.StringBuilder sScript = new System.Text.StringBuilder(); sScript.Append(Environment.NewLine + "<SCRIPT language=\"javascript\">" + Environment.NewLine); sScript.Append("function fnTrapKD(btn) {" + Environment.NewLine); sScript.Append(" if (document.all){" + Environment.NewLine); sScript.Append(" if (event.keyCode == 13)" + Environment.NewLine); sScript.Append(" { " + Environment.NewLine); sScript.Append(" event.returnValue=false;" + Environment.NewLine); sScript.Append(" event.cancel = true;" + Environment.NewLine); sScript.Append(" btn.click();" + Environment.NewLine); sScript.Append(" } " + Environment.NewLine); sScript.Append(" } " + Environment.NewLine); sScript.Append("}" + Environment.NewLine); sScript.Append("</SCRIPT>" + Environment.NewLine); checkBox.Attributes.Add("onkeydown", "fnTrapKD(document.all." + inputButton.ClientID + ")"); //Page.RegisterStartupScript("ForceDefaultToScript", sScript.ToString()); Page.ClientScript.RegisterStartupScript(Page.GetType(), "ForceDefaultToScript", sScript.ToString()); } catch (System.Exception ex) { UIManager.AdministrationManager.DiagnosticError(ex); } }
protected void savedSearchResultsRepeater_ItemDataBound(object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e) { if (e.Item.ItemType == System.Web.UI.WebControls.ListItemType.Item || e.Item.ItemType == System.Web.UI.WebControls.ListItemType.AlternatingItem) { System.Data.DataRowView currentRow = e.Item.DataItem as System.Data.DataRowView; string itemLinkValue = currentRow["HitHighlightedPropertiesXml"] as string; System.Xml.Linq.XElement xEl = System.Xml.Linq.XElement.Parse(itemLinkValue); System.Xml.Linq.XElement hhTitleElement = (from node in xEl.Elements() where node.Name == "HHTitle" select node).FirstOrDefault(); System.Xml.Linq.XElement hhUrlElement = (from node in xEl.Elements() where node.Name == "HHUrl" select node).FirstOrDefault(); string hhTitle = hhTitleElement != null ? hhTitleElement.Value : string.Empty; string hhUrl = hhUrlElement != null ? hhUrlElement.Value : string.Empty;; string iconUrl = Microsoft.SharePoint.Publishing.Fields.LinkFieldValue.GetDefaultIconUrl(currentRow["Url"] as string, SPContext.Current.Web); System.Web.UI.WebControls.Image docTypeImage = e.Item.FindControl("docTypeImage") as System.Web.UI.WebControls.Image; if (docTypeImage != null) { docTypeImage.ImageUrl = iconUrl; } System.Web.UI.WebControls.HyperLink titleLink = e.Item.FindControl("titleLink") as System.Web.UI.WebControls.HyperLink; if (titleLink != null) { titleLink.NavigateUrl = hhUrl; titleLink.Text = hhTitle; } System.Web.UI.WebControls.CheckBox reviewedCheckBox = e.Item.FindControl("reviewedCheckBox") as System.Web.UI.WebControls.CheckBox; if (reviewedCheckBox != null) { reviewedCheckBox.InputAttributes.Add("onclick", String.Format("SaveSearchResultData({0}, {1}, {2});", currentRow["Id"], "'reviewed'", "$('#" + reviewedCheckBox.ClientID + "').prop('checked')") ); reviewedCheckBox.Checked = (currentRow.Row.IsNull("Reviewed")) ? false: (bool)currentRow["Reviewed"]; } System.Web.UI.WebControls.CheckBox includeInSetCheckBox = e.Item.FindControl("includeInSetCheckBox") as System.Web.UI.WebControls.CheckBox; if (includeInSetCheckBox != null) { includeInSetCheckBox.InputAttributes.Add("onclick", String.Format("SaveSearchResultData({0}, {1}, {2});", currentRow["Id"], "'IncludeInSet'", "$('#" + includeInSetCheckBox.ClientID + "').prop('checked')") ); includeInSetCheckBox.Checked = (currentRow.Row.IsNull("IncludeInSet")) ? false : (bool)currentRow["IncludeInSet"]; } } }
private void BatchHuifu_click(object sender, System.EventArgs e) { string text = ""; ManagerHelper.CheckPrivilege(Privilege.DeleteMember); foreach (System.Web.UI.WebControls.GridViewRow gridViewRow in this.grdMemberList.Rows) { System.Web.UI.WebControls.CheckBox checkBox = (System.Web.UI.WebControls.CheckBox)gridViewRow.FindControl("checkboxCol"); if (checkBox.Checked) { text = text + this.grdMemberList.DataKeys[gridViewRow.RowIndex].Value.ToString() + ","; } } text = text.TrimEnd(new char[] { ',' }); if (string.IsNullOrEmpty(text)) { this.ShowMsg("请先选择要恢复的会员账号!", false); return; } if (MemberHelper.BacthHuifu(text)) { this.ShowMsg("成功恢复了选择的会员!", true); this.BindData(); } }
private void lkbtnDeleteCheck_Click(object sender, System.EventArgs e) { int num = 0; foreach (System.Web.UI.WebControls.GridViewRow gridViewRow in this.grdCountDownsList.Rows) { System.Web.UI.WebControls.CheckBox checkBox = (System.Web.UI.WebControls.CheckBox)gridViewRow.FindControl("checkboxCol"); if (checkBox.Checked) { num++; int countDownId = System.Convert.ToInt32(this.grdCountDownsList.DataKeys[gridViewRow.RowIndex].Value, System.Globalization.CultureInfo.InvariantCulture); PromoteHelper.DeleteCountDown(countDownId); } } if (num != 0) { this.BindCountDown(); this.ShowMsg(string.Format(System.Globalization.CultureInfo.InvariantCulture, "成功删除\"{0}\"条限时抢购活动", new object[] { num }), true); return; } this.ShowMsg("请先选择需要删除的限时抢购活动", false); }
private void GroupCheck_Click(object sender, System.EventArgs e) { System.Collections.Generic.IList <int> list = new System.Collections.Generic.List <int>(); foreach (System.Web.UI.WebControls.GridViewRow gridViewRow in this.grdMemberList.Rows) { System.Web.UI.WebControls.CheckBox checkBox = (System.Web.UI.WebControls.CheckBox)gridViewRow.FindControl("checkboxCol"); if (checkBox.Checked) { int item = 0; if (int.TryParse(this.grdMemberList.DataKeys[gridViewRow.RowIndex].Value.ToString(), out item)) { list.Add(item); } } } if (list.Count == 0) { this.ShowMsg("请先选择需要设置分组的用户", false); return; } if (!string.IsNullOrEmpty(this.hdCustomGroup.Value)) { System.Collections.Generic.IList <int> list2 = new System.Collections.Generic.List <int>(); if (this.hdCustomGroup.Value.Contains(",")) { string[] array = this.hdCustomGroup.Value.Split(new char[] { ',' }); for (int i = 0; i < array.Length; i++) { string s = array[i]; int item2 = 0; if (int.TryParse(s, out item2)) { list2.Add(item2); } } } else if (!this.hdCustomGroup.Value.Equals("-1")) { int item3 = 0; if (int.TryParse(this.hdCustomGroup.Value, out item3)) { list2.Add(item3); } } foreach (int current in list) { CustomGroupingHelper.SetUserCustomGroup(current, list2); } this.ShowMsg("设置成功!", true); this.BindData(); return; } this.ShowMsg("请先选择分组", false); }
protected override Control CreateControl() { _control = new CheckBox { ID = ("c" + _field.Name), ToolTip = _field.Description }; return(_control); }
/// <summary> /// CheckBox控件翻译,从数据库中取值 /// </summary> /// <param name="button">要翻译的服务器控件</param> /// <param name="keyCode">字典键值</param> /// <param name="defaultText">默认值</param> public static void TranslationCheckBoxDB(System.Web.UI.WebControls.CheckBox checkBox, string keyCode, string defaultText) { string tlText = string.Empty; tlText = Translate(keyCode); if (tlText == "") { tlText = defaultText; } checkBox.Text = tlText; }
/// <summary> /// CheckBox 선택 셋팅 /// </summary> /// <param name="objCheckBox"></param> /// <returns></returns> public static string GetCheckBox(System.Web.UI.WebControls.CheckBox objCheckBox) { if (objCheckBox.Checked == true) { return("1"); } else { return("0"); } }
/// <summary> /// 设定Checkbox控制TextBox事件, /// </summary> /// <param name="ChkObj">Checkbox控件</param> /// <param name="HtmlObjId">控件TextBox ID,多个ID以,号分开</param> public static void SetChkAttrib(System.Web.UI.WebControls.CheckBox ChkObj, string HtmlObjId) { #region string[] StrId = HtmlObjId.Split(','); string JsCode = ""; for (int i = 0; i < StrId.Length; i++) { JsCode = JsCode + string.Format("EnableCtrl(this,'{0}');", StrId[i]); } ChkObj.Attributes.Add("onclick", JsCode); #endregion }
protected override void AttachChildControls() { this.chkAgree = (System.Web.UI.WebControls.CheckBox) this.FindControl("chkAgree"); this.txtUserName = (System.Web.UI.WebControls.TextBox) this.FindControl("txtUserName"); this.txtPassword = (System.Web.UI.WebControls.TextBox) this.FindControl("txtPassword"); this.txtPassword2 = (System.Web.UI.WebControls.TextBox) this.FindControl("txtPassword2"); this.txtEmail = (System.Web.UI.WebControls.TextBox) this.FindControl("txtEmail"); this.txtCellPhone = (System.Web.UI.WebControls.TextBox) this.FindControl("txtCellPhone"); this.txtNumber = (System.Web.UI.WebControls.TextBox) this.FindControl("txtNumber"); this.btnRegister = ButtonManager.Create(this.FindControl("btnRegister")); PageTitle.AddSiteNameTitle("会员注册", Hidistro.Membership.Context.HiContext.Current.Context); this.btnRegister.Click += new System.EventHandler(this.btnRegister_Click); }
private void GradeCheck_Click(object sender, System.EventArgs e) { string text = ""; ManagerHelper.CheckPrivilege(Privilege.DeleteMember); foreach (System.Web.UI.WebControls.GridViewRow gridViewRow in this.grdMemberList.Rows) { System.Web.UI.WebControls.CheckBox checkBox = (System.Web.UI.WebControls.CheckBox)gridViewRow.FindControl("checkboxCol"); if (checkBox.Checked) { text = text + this.grdMemberList.DataKeys[gridViewRow.RowIndex].Value.ToString() + ","; } } text = text.TrimEnd(new char[] { ',' }); if (text.Length <= 0) { this.ShowMsg("请先选择要修改等级的用户", false); return; } int gradeId = System.Convert.ToInt32(this.GradeCheckList.SelectedValue); int num = MemberHelper.SetUsersGradeId(text, gradeId); if (num > 0) { string[] array = text.Split(new char[] { ',' }); for (int i = 0; i < array.Length; i++) { MemberInfo member = MemberHelper.GetMember(int.Parse(array[i])); if (member != null) { try { Messenger.SendWeiXinMsg_MemberGradeChange(member); } catch { } } } } this.ShowMsg(string.Format("成功修改了{0}个用户的等级", num), true); this.BindData(); }
private void btnMoveImageData_Click(object sender, System.EventArgs e) { System.Collections.Generic.List <int> pList = new System.Collections.Generic.List <int>(); int pTypeId = System.Convert.ToInt32(this.dropImageFtp.SelectedItem.Value); foreach (System.Web.UI.WebControls.DataListItem item in this.photoDataList.Controls) { System.Web.UI.WebControls.CheckBox box = (System.Web.UI.WebControls.CheckBox)item.FindControl("checkboxCol"); if (box != null && box.Checked) { int num2 = (int)this.photoDataList.DataKeys[item.ItemIndex]; pList.Add(num2); } } if (GalleryHelper.MovePhotoType(pList, pTypeId) > 0) { this.ShowMsg("图片移动成功!", true); } this.BindImageData(); }
private string GetSelectedOrganization() { List <string> organization_id = new List <string>(); foreach (System.Web.UI.WebControls.GridViewRow row in grdGetOrganization.Rows) { if (row.RowType == System.Web.UI.WebControls.DataControlRowType.DataRow) { System.Web.UI.WebControls.CheckBox chkRow = (row.Cells[0].FindControl("chkRow") as System.Web.UI.WebControls.CheckBox); if (chkRow.Checked) { //string name = row.Cells[1].Text; //string country = (row.Cells[2].FindControl("lblCountry") as Label).Text; //dt.Rows.Add(name, country); organization_id.Add(row.Cells[5].Text); } } } return(String.Join("", organization_id)); }
private void btnDelete_Click(object sender, System.EventArgs e) { bool flag = true; bool flag2 = true; foreach (System.Web.UI.WebControls.DataListItem item in this.photoDataList.Controls) { System.Web.UI.WebControls.CheckBox box = (System.Web.UI.WebControls.CheckBox)item.FindControl("checkboxCol"); System.Web.UI.WebControls.HiddenField field = (System.Web.UI.WebControls.HiddenField)item.FindControl("HiddenFieldImag"); if (box != null && box.Checked) { flag2 = false; try { int photoId = (int)this.photoDataList.DataKeys[item.ItemIndex]; StoreHelper.DeleteImage(field.Value); if (!GalleryHelper.DeletePhoto(photoId)) { flag = false; } } catch { this.ShowMsg("删除文件错误", false); this.BindImageData(); } } } if (flag2) { this.ShowMsg("未选择删除的图片", false); } else { if (flag) { this.ShowMsg("删除图片成功", true); } this.BindImageData(); } }
public static bool UseRealtime(System.Web.UI.WebControls.CheckBox cb) { int H = DateTime.UtcNow.AddHours(-4).Hour; if (IncludeTodayQuote == 1) { return(true); } else if (Config.IncludeTodayQuote == 0) { return(false); } else if (Config.IncludeTodayQuote == 4 && H >= MarketOpen && H < MarketClose) { return(true); } else { return(cb.Visible && cb.Checked); } }
/// <summary> /// 得到DataGrid中checkbox选择的值字串 /// </summary> /// <param name="dgName">DataGrid对象</param> /// <param name="chkSelName">checkbox名称</param> /// <param name="indexSelInDg">checkbox在DataGrid中的位置Index</param> /// <returns>返回已选择的checkbox的值串</returns> public static string getSelId(System.Web.UI.WebControls.DataGrid dgName, string chkSelName, int indexSelInDg) { System.Web.UI.WebControls.CheckBox _cb = new System.Web.UI.WebControls.CheckBox(); System.Text.StringBuilder _sb = new System.Text.StringBuilder(); int i, j = dgName.Items.Count; for (i = 0; i < j; i++) { _cb = (System.Web.UI.WebControls.CheckBox)dgName.Items[i].Cells[indexSelInDg].FindControl(chkSelName); if (_cb.Checked) { //Response.Write(MyDataGrid.Items[i].Cells[1].Text.Trim()); _sb.Append(dgName.Items[i].Cells[indexSelInDg].Text.Trim()); _sb.Append(","); } } string strNames = _sb.ToString(); strNames = strNames.Substring(0, strNames.Length - 1); return(strNames); }
public void FindControls() { System.Web.UI.Control ctrl = this.Grid.Page.FindControl("chbSelectAll"); if (ctrl is System.Web.UI.WebControls.CheckBox) { this._chbSelectAll = (System.Web.UI.WebControls.CheckBox)ctrl; } ctrl = this.Grid.Page.FindControl("pagerToolBar"); if (ctrl is PagerToolBar) { this._pagerToolBar = (PagerToolBar)ctrl; } ctrl = this.Grid.Page.FindControl("pagerSizeSelector"); if (ctrl is PagerSizeSelector) { this._pagerSizeSelector = (PagerSizeSelector)ctrl; } }
private void btnSendMessage_Click(object sender, System.EventArgs e) { SiteSettings siteSetting = this.GetSiteSetting(); string sMSSender = siteSetting.SMSSender; if (string.IsNullOrEmpty(sMSSender)) { this.ShowMsg("请先选择发送方式", false); return; } ConfigData configData = null; if (siteSetting.SMSEnabled) { configData = new ConfigData(HiCryptographer.Decrypt(siteSetting.SMSSettings)); } if (configData == null) { this.ShowMsg("请先选择发送方式并填写配置信息", false); return; } if (!configData.IsValid) { string text = ""; foreach (string current in configData.ErrorMsgs) { text += Formatter.FormatErrorMessage(current); } this.ShowMsg(text, false); return; } string text2 = this.txtmsgcontent.Value.Trim(); if (string.IsNullOrEmpty(text2)) { this.ShowMsg("请先填写发送的内容信息", false); return; } int smsValidCount = this.GetSmsValidCount(); string text3 = null; foreach (System.Web.UI.WebControls.GridViewRow gridViewRow in this.grdMemberList.Rows) { System.Web.UI.WebControls.CheckBox checkBox = (System.Web.UI.WebControls.CheckBox)gridViewRow.FindControl("checkboxCol"); if (checkBox.Checked) { string text4 = ((System.Web.UI.DataBoundLiteralControl)gridViewRow.Controls[4].Controls[0]).Text.Trim().Replace("<div></div>", "").Replace(" ", ""); System.Web.UI.WebControls.HiddenField hiddenField = (System.Web.UI.WebControls.HiddenField)gridViewRow.FindControl("hidCellPhone"); text4 = hiddenField.Value; if (!string.IsNullOrEmpty(text4) && System.Text.RegularExpressions.Regex.IsMatch(text4, "^(13|14|15|18)\\d{9}$")) { text3 = text3 + text4 + ","; } } } if (text3 == null) { this.ShowMsg("请先选择要发送的会员或检测所选手机号格式是否正确", false); return; } text3 = text3.Substring(0, text3.Length - 1); string[] array; if (text3.Contains(",")) { array = text3.Split(new char[] { ',' }); } else { array = new string[] { text3 }; } if (smsValidCount < array.Length) { this.ShowMsg("发送失败,您的剩余短信条数不足。可用条数:" + smsValidCount.ToString(), false); return; } SMSSender sMSSender2 = SMSSender.CreateInstance(sMSSender, configData.SettingsXml); string msg; bool success = sMSSender2.Send(array, text2, out msg); this.ShowMsg(msg, success); this.ValidSmsNum = this.GetSmsValidCount().ToString(); }
/// <summary> /// Creates datarows pertaining to the controls in the panel and updates them /// </summary> /// <param name="PanelControls">Panel with contains the collection </param> /// <param name="objTemp">Object which contains values regarding the documentrow</param> /// <returns>true on successful update</returns> public bool UpdateData(System.Web.UI.WebControls.Panel PanelControls, ref object objTemp) { try { objCommonBase = new Streamline.DataService.CommonBase(); System.Collections.Hashtable hashTableTemp = (System.Collections.Hashtable)objTemp; string dataFileTemp = PanelControls.Attributes["DataFile"]; string dataFileAfterUpdate = PanelControls.Attributes["DataFileAfterUpdate"]; //This statement is used to get the collections of controls in the panel. //GetEnumerator is a forward only and light weight cursor.Hence it is more efficient than // For each control in Panel. System.Collections.IEnumerator eControls = PanelControls.Controls.GetEnumerator(); datasetMain = new DataSet(); if (!String.IsNullOrEmpty(dataFileAfterUpdate)) { datasetMain.ReadXml(PATH + System.Web.HttpContext.Current.Session.SessionID + "\\" + dataFileAfterUpdate, XmlReadMode.ReadSchema); datasetMain.AcceptChanges(); } else { datasetMain.ReadXmlSchema(PATH + dataFileTemp); } newRow = true; //if(hashTableTemp.ContainsKey("DocumentId")) // AddDataRowValues(tableName, fieldName, hdnTemp.Value, primaryKey == "True" ? true : false); //if(hashTableTemp.ContainsKey("Version")) // AddDataRowValues(tableName, fieldName, hdnTemp.Value, primaryKey == "True" ? true : false); while (eControls.MoveNext()) { object objCurrentControl = eControls.Current; switch (objCurrentControl.GetType().ToString()) { case "System.Web.UI.HtmlControls.HtmlInputHidden": { System.Web.UI.HtmlControls.HtmlInputHidden hdnTemp = (System.Web.UI.HtmlControls.HtmlInputHidden)objCurrentControl; string primaryKey = hdnTemp.Attributes["PrimaryKey"]; if (!String.IsNullOrEmpty(primaryKey)) { string fieldName = hdnTemp.Attributes["FieldName"]; string tableName = hdnTemp.Attributes["TableName"]; if (primaryKey == "True") { if (String.IsNullOrEmpty(hdnTemp.Value)) { if (hashTableTemp.ContainsKey(fieldName)) { hdnTemp.Value = hashTableTemp[fieldName].ToString(); } } else { newRow = false; } AddDataRowValues(tableName, fieldName, hdnTemp.Value, primaryKey == "True" ? true : false); } } break; } case "System.Web.UI.WebControls.TextBox": { System.Web.UI.WebControls.TextBox txtTemp = (System.Web.UI.WebControls.TextBox)objCurrentControl; string fieldName = txtTemp.Attributes["FieldName"]; string tableName = txtTemp.Attributes["TableName"]; AddDataRowValues(tableName, fieldName, txtTemp.Text, false); break; } case "System.Web.UI.WebControls.CheckBox": { System.Web.UI.WebControls.CheckBox chkTemp = (System.Web.UI.WebControls.CheckBox)objCurrentControl; string fieldName = chkTemp.Attributes["FieldName"]; string tableName = chkTemp.Attributes["TableName"]; AddDataRowValues(tableName, fieldName, chkTemp.Checked == true ? "Y" : "N", false); break; } case "System.Web.UI.WebControls.DropDownList": { System.Web.UI.WebControls.DropDownList ddlTemp = (System.Web.UI.WebControls.DropDownList)objCurrentControl; string fieldName = ddlTemp.Attributes["FieldName"]; string tableName = ddlTemp.Attributes["TableName"]; AddDataRowValues(tableName, fieldName, ddlTemp.SelectedValue, false); break; } case "System.Web.UI.WebControls.RadioButton": { System.Web.UI.WebControls.RadioButton rbTemp = (System.Web.UI.WebControls.RadioButton)objCurrentControl; string fieldName = rbTemp.Attributes["FieldName"]; string tableName = rbTemp.Attributes["TableName"]; string value = rbTemp.Attributes["Value"]; if (rbTemp.Checked == true) { AddDataRowValues(tableName, fieldName, value, false); } break; } } } //Merging the documents table to the maindataset datasetMain.Merge(getDocumentTable(objTemp)); DataSet dsUpdated = objCommonBase.UpdateDocuments(datasetMain); string updateFile = System.Guid.NewGuid().ToString() + ".xml"; dsUpdated.WriteXml(PATH + System.Web.HttpContext.Current.Session.SessionID + "\\" + updateFile, XmlWriteMode.WriteSchema); PanelControls.Attributes["DataFileAfterUpdate"] = updateFile; // setting back the updated documentid and version id to the arguments passed by the parent class if (dsUpdated.Tables.Count > 0) { if (dsUpdated.Tables[0].Columns.Contains("DocumentId")) { if (dsUpdated.Tables[0].Rows.Count > 0) { if (hashTableTemp.ContainsKey("DocumentId")) { hashTableTemp["DocumentId"] = Convert.ToInt32(dsUpdated.Tables[0].Rows[0]["DocumentId"]); } else { hashTableTemp.Add("DocumentId", Convert.ToInt32(dsUpdated.Tables[0].Rows[0]["DocumentId"])); } if (hashTableTemp.ContainsKey("Version")) { hashTableTemp["Version"] = Convert.ToInt32(dsUpdated.Tables[0].Rows[0]["Version"]); } else { hashTableTemp.Add("Version", Convert.ToInt32(dsUpdated.Tables[0].Rows[0]["Version"])); } } } } // SetControlValues(PanelControls, dsUpdated); return(true); } catch (Exception ex) { return(false); } }
private void GenCheckBoxTemplate(String ExtraName) { if (ExtraName == "") { System.Web.UI.WebControls.Label aLabel = new System.Web.UI.WebControls.Label(); aLabel.ID = "l" + FTableName + FFieldItem.DataField + ExtraName + "GridView"; aLabel.ToolTip = FFieldItem.DataField; FContainer.Controls.Add(aLabel); Boolean Found = false; foreach (System.Web.UI.WebControls.Label bLabel in aLabelList) { if (String.Compare(aLabel.ID, bLabel.ID) == 0) { Found = true; break; } } if (!Found) { aLabelList.Add(aLabel); } } else { System.Web.UI.WebControls.CheckBox aCheckBox = new System.Web.UI.WebControls.CheckBox(); aCheckBox.ID = "wdtp" + FTableName + FFieldItem.DataField + ExtraName + "GridView"; aCheckBox.ToolTip = FFieldItem.DataField; //aPicker.Text = String.Format("'<%# Bind(\"{0}\") %>'", FFieldItem.DataField); FContainer.Controls.Add(aCheckBox); Boolean Found = false; foreach (System.Web.UI.WebControls.CheckBox bWebPicker in aWebCheckBoxList) { if (String.Compare(aCheckBox.ID, bWebPicker.ID) == 0) { Found = true; break; } } if (!Found) { aWebCheckBoxList.Add(aCheckBox); //Add AddNewRowControlItem to WebGridView if (ExtraName == "F") { if (FWebGridView != null) { Found = false; foreach (AddNewRowControlItem aControlItem in FWebGridView.AddNewRowControls) { if (aControlItem.FieldName.CompareTo(FFieldItem.DataField) == 0) { Found = true; break; } } if (!Found) { AddNewRowControlItem aItem = new AddNewRowControlItem(); aItem.ControlID = "wdtp" + FTableName + FFieldItem.DataField + ExtraName; aItem.ControlType = WebGridView.AddNewRowControlType.CheckBox; aItem.FieldName = FFieldItem.DataField; FWebGridView.AddNewRowControls.Add(aItem); } } } } } }
public static int IndexGVCheckBox(object sender) { System.Web.UI.WebControls.CheckBox ct = (System.Web.UI.WebControls.CheckBox)sender; System.Web.UI.WebControls.GridViewRow gvRow = (System.Web.UI.WebControls.GridViewRow)ct.NamingContainer; return(gvRow.RowIndex); }
public GridHelperForRPT(UltraWebGrid grid, System.Web.UI.WebControls.CheckBox chbSelectAll) { GridHelper = new GridHelper(grid, chbSelectAll); ApplyDefaultStyle(); }
/// <summary> /// CheckBox 선택 셋팅 /// </summary> /// <param name="objCheckBox"></param> /// <param name="strChecked"></param> public static void SetCheckBox(System.Web.UI.WebControls.CheckBox objCheckBox, string strChecked) { objCheckBox.Checked = (strChecked == "1") ? true : false; }
/// <summary> /// 服务器控件的翻译,从数据库中取值 /// </summary> /// <param name="control">要翻译的控件</param> /// <param name="items">二维数组型参数,第二维第一个为字典键值,第二个为默认值</param> public void TranControlsDB(object control, string[][] items) { switch (control.GetType().ToString()) // { case "System.Web.UI.WebControls.GridView": System.Web.UI.WebControls.GridView gv = (System.Web.UI.WebControls.GridView)control; Translation.TranslationGridViewDB(gv, items); break; case "System.Web.UI.WebControls.DataGrid": System.Web.UI.WebControls.DataGrid dg = (System.Web.UI.WebControls.DataGrid)control; Translation.TranslationDataGridDB(dg, items); break; case "System.Web.UI.WebControls.RadioButtonList": System.Web.UI.WebControls.RadioButtonList rbl = (System.Web.UI.WebControls.RadioButtonList)control; Translation.TranslationRadioButtonListDB(rbl, items); break; case "System.Web.UI.WebControls.DropDownList": System.Web.UI.WebControls.DropDownList ddl = (System.Web.UI.WebControls.DropDownList)control; Translation.TranslationDropDownListDB(ddl, items); break; case "System.Web.UI.WebControls.CheckBoxList": System.Web.UI.WebControls.CheckBoxList chkl = (System.Web.UI.WebControls.CheckBoxList)control; Translation.TranslationCheckBoxListDB(chkl, items); break; case "System.Web.UI.WebControls.Button": System.Web.UI.WebControls.Button button = (System.Web.UI.WebControls.Button)control; Translation.TranslationButtonDB(button, items[0][0], items[0][1]); break; case "System.Web.UI.WebControls.LinkButton": System.Web.UI.WebControls.LinkButton lbtn = (System.Web.UI.WebControls.LinkButton)control; Translation.TranslationLinkButtonDB(lbtn, items[0][0], items[0][1]); break; case "System.Web.UI.WebControls.ImageButton": System.Web.UI.WebControls.ImageButton imgBtn = (System.Web.UI.WebControls.ImageButton)control; Translation.TranslationImageButtonDB(imgBtn, items[0][0], items[0][1]); break; case "System.Web.UI.WebControls.HyperLink": System.Web.UI.WebControls.HyperLink hl = (System.Web.UI.WebControls.HyperLink)control; Translation.TranslationHyperLinkDB(hl, items[0][0], items[0][1]); break; case "System.Web.UI.WebControls.Label": System.Web.UI.WebControls.Label label = (System.Web.UI.WebControls.Label)control; Translation.TranslationLabelDB(label, items[0][0], items[0][1]); break; case "System.Web.UI.WebControls.CheckBox": System.Web.UI.WebControls.CheckBox chk = (System.Web.UI.WebControls.CheckBox)control; Translation.TranslationCheckBoxDB(chk, items[0][0], items[0][1]); break; case "System.Web.UI.WebControls.RadioButton": System.Web.UI.WebControls.RadioButton rbtn = (System.Web.UI.WebControls.RadioButton)control; Translation.TranslationRadioButtonDB(rbtn, items[0][0], items[0][1]); break; case "System.Web.UI.WebControls.RequiredFieldValidator": System.Web.UI.WebControls.RequiredFieldValidator rfv = (System.Web.UI.WebControls.RequiredFieldValidator)control; Translation.TranslationRequiredFieldValidatorDB(rfv, items[0][0], items[0][1]); break; case "System.Web.UI.WebControls.RangeValidator": System.Web.UI.WebControls.RangeValidator rv = (System.Web.UI.WebControls.RangeValidator)control; Translation.TranslationRangeValidatorDB(rv, items[0][0], items[0][1]); break; case "System.Web.UI.WebControls.CompareValidator": System.Web.UI.WebControls.CompareValidator cv = (System.Web.UI.WebControls.CompareValidator)control; Translation.TranslationCompareValidatorDB(cv, items[0][0], items[0][1]); break; case "System.Web.UI.WebControls.RegularExpressionValidator": System.Web.UI.WebControls.RegularExpressionValidator rev = (System.Web.UI.WebControls.RegularExpressionValidator)control; Translation.TranslationRegularExpressionValidatorDB(rev, items[0][0], items[0][1]); break; } }
/// <summary> /// 填充model /// </summary> /// <param name="entity"></param> /// <param name="control"></param> public static void FillModel(Object entity, WebUI.Control control) { if (entity == null || control == null) { return; } NameValueCollection formData = HttpContext.Current.Request.Form; PropertyInfo[] propertyList = entity.GetProperties(); foreach (PropertyInfo pi in propertyList) { string ctlId = string.Format(IdFormat, pi.Name); WebUI.Control ctl = control.FindControl(ctlId); if (ctl == null) { #region 处理HMTL标签 if (formData[ctlId] != null) { entity.SetPropertyValue(pi.Name, formData[ctlId]); } #endregion continue; } Type ctlType = ctl.GetType(); #region 处理服务器控件 if (ctlType == typeof(WebUI.WebControls.TextBox))//文本框 { entity.SetPropertyValue(pi.Name, ((WebUI.WebControls.TextBox)ctl).Text); } else if (ctlType == typeof(WebUI.WebControls.Image))//图片 { entity.SetPropertyValue(pi.Name, ((WebUI.WebControls.Image)ctl).ImageUrl); } else if (ctlType == typeof(WebUI.WebControls.DropDownList))//选择框 { entity.SetPropertyValue(pi.Name, ((WebUI.WebControls.DropDownList)ctl).SelectedValue); } else if (ctlType == typeof(WebUI.WebControls.HiddenField))//隐藏域 { entity.SetPropertyValue(pi.Name, ((WebUI.WebControls.HiddenField)ctl).Value); } else if (ctlType == typeof(WebUI.WebControls.RadioButton))//单选框 { WebUI.WebControls.RadioButton rb = (WebUI.WebControls.RadioButton)ctl; if (rb.Checked) { entity.SetPropertyValue(pi.Name, rb.Text); } else { entity.SetPropertyValue(pi.Name, ""); } } else if (ctlType == typeof(WebUI.WebControls.CheckBox))//复选框 { WebUI.WebControls.CheckBox ck = (WebUI.WebControls.CheckBox)ctl; if (ck.Checked) { entity.SetPropertyValue(pi.Name, ck.Text); } else { entity.SetPropertyValue(pi.Name, ""); } } else if (ctlType == typeof(WebUI.WebControls.CheckBoxList))//复选框列表 { WebUI.WebControls.CheckBoxList ck = (WebUI.WebControls.CheckBoxList)ctl; string rs = ""; foreach (WebUI.WebControls.ListItem li in ck.Items) { if (li.Selected) { rs += "," + li.Value; } } if (rs.Length > 1) { rs = rs.Substring(1); } entity.SetPropertyValue(pi.Name, rs); } else if (ctlType == typeof(WebUI.WebControls.RadioButtonList))//单框列表 { WebUI.WebControls.RadioButtonList ck = (WebUI.WebControls.RadioButtonList)ctl; entity.SetPropertyValue(pi.Name, ck.SelectedValue); } else if (ctlType == typeof(WebUI.WebControls.ListBox))//列表框 { WebUI.WebControls.ListBox ck = (WebUI.WebControls.ListBox)ctl; string rs = ""; foreach (WebUI.WebControls.ListItem li in ck.Items) { if (li.Selected) { rs += "," + li.Value; } } if (rs.Length > 1) { rs = rs.Substring(1); } entity.SetPropertyValue(pi.Name, rs); } #endregion #region 处理不同Html控件 else if (ctlType == typeof(WebUI.HtmlControls.HtmlInputText))//文本域 { WebUI.HtmlControls.HtmlInputText ct = (WebUI.HtmlControls.HtmlInputText)ctl; entity.SetPropertyValue(pi.Name, ct.Value); } else if (ctlType == typeof(WebUI.HtmlControls.HtmlTextArea))//文本域 { WebUI.HtmlControls.HtmlTextArea ct = (WebUI.HtmlControls.HtmlTextArea)ctl; entity.SetPropertyValue(pi.Name, ct.Value); } else if (ctlType == typeof(WebUI.HtmlControls.HtmlSelect))//选择域 { WebUI.HtmlControls.HtmlSelect ct = (WebUI.HtmlControls.HtmlSelect)ctl; entity.SetPropertyValue(pi.Name, ct.Items[ct.SelectedIndex].Value); } else if (ctlType == typeof(WebUI.HtmlControls.HtmlInputHidden))////隐藏域 { WebUI.HtmlControls.HtmlInputHidden ct = (WebUI.HtmlControls.HtmlInputHidden)ctl; entity.SetPropertyValue(pi.Name, ct.Value); } else if (ctlType == typeof(WebUI.HtmlControls.HtmlInputRadioButton))//单选域 { WebUI.HtmlControls.HtmlInputRadioButton rb = (WebUI.HtmlControls.HtmlInputRadioButton)ctl; if (rb.Checked) { entity.SetPropertyValue(pi.Name, rb.Value); } } else if (ctlType == typeof(WebUI.HtmlControls.HtmlInputCheckBox))//复选域 { WebUI.HtmlControls.HtmlInputCheckBox ck = (WebUI.HtmlControls.HtmlInputCheckBox)ctl; if (ck.Checked) { entity.SetPropertyValue(pi.Name, ck.Value); } } else if (ctlType == typeof(WebUI.HtmlControls.HtmlInputPassword))//密码域 { WebUI.HtmlControls.HtmlInputPassword ck = (WebUI.HtmlControls.HtmlInputPassword)ctl; entity.SetPropertyValue(pi.Name, ck.Value); } #endregion } }
/// <summary> /// 清理表单 /// </summary> /// <param name="control"></param> public static void ClearForm(WebUI.Control control) { if (control == null) { return; } foreach (WebUI.Control ctl in control.Controls) { Type type = ctl.GetType(); #region 处理服务器控件 if (type == typeof(WebUI.WebControls.TextBox))//文本框 { WebUI.WebControls.TextBox box = ((WebUI.WebControls.TextBox)ctl); box.Text = ""; if (box.Attributes["isNumber"] != null) { box.Text = "0"; } } else if (type == typeof(WebUI.WebControls.DropDownList))//选择框 { ((WebUI.WebControls.DropDownList)ctl).SelectedIndex = -1; } else if (type == typeof(WebUI.WebControls.HiddenField))//隐藏域 { ((WebUI.WebControls.HiddenField)ctl).Value = ""; } else if (type == typeof(WebUI.WebControls.RadioButton))//单选框 { WebUI.WebControls.RadioButton rb = (WebUI.WebControls.RadioButton)ctl; rb.Checked = false; } else if (type == typeof(WebUI.WebControls.CheckBox))//复选框 { WebUI.WebControls.CheckBox ck = (WebUI.WebControls.CheckBox)ctl; ck.Checked = false; } else if (type == typeof(WebUI.WebControls.CheckBoxList))//复选框列表 { WebUI.WebControls.CheckBoxList ck = (WebUI.WebControls.CheckBoxList)ctl; foreach (WebUI.WebControls.ListItem li in ck.Items) { li.Selected = false; } } else if (type == typeof(WebUI.WebControls.RadioButtonList))//单框列表 { WebUI.WebControls.RadioButtonList ck = (WebUI.WebControls.RadioButtonList)ctl; foreach (WebUI.WebControls.ListItem li in ck.Items) { li.Selected = false; } } else if (type == typeof(WebUI.WebControls.ListBox))//列表框 { WebUI.WebControls.ListBox ck = (WebUI.WebControls.ListBox)ctl; foreach (WebUI.WebControls.ListItem li in ck.Items) { li.Selected = false; } } #endregion #region 处理不同Html控件 else if (type == typeof(WebUI.HtmlControls.HtmlInputText))//文本域 { WebUI.HtmlControls.HtmlInputText ct = (WebUI.HtmlControls.HtmlInputText)ctl; ct.Value = ""; if (ct.Attributes["isNumber"] != null) { ct.Value = "0"; } } else if (type == typeof(WebUI.HtmlControls.HtmlTextArea))//文本域 { WebUI.HtmlControls.HtmlTextArea ct = (WebUI.HtmlControls.HtmlTextArea)ctl; ct.Value = ""; } else if (type == typeof(WebUI.HtmlControls.HtmlSelect))//选择域 { WebUI.HtmlControls.HtmlSelect ct = (WebUI.HtmlControls.HtmlSelect)ctl; ct.SelectedIndex = -1; } else if (type == typeof(WebUI.HtmlControls.HtmlInputHidden))////隐藏域 { WebUI.HtmlControls.HtmlInputHidden ct = (WebUI.HtmlControls.HtmlInputHidden)ctl; ct.Value = ""; if (ct.Attributes["isNumber"] != null) { ct.Value = "0"; } } else if (type == typeof(WebUI.HtmlControls.HtmlInputRadioButton))//单选域 { WebUI.HtmlControls.HtmlInputRadioButton rb = (WebUI.HtmlControls.HtmlInputRadioButton)ctl; rb.Checked = false; } else if (type == typeof(WebUI.HtmlControls.HtmlInputCheckBox))//复选域 { WebUI.HtmlControls.HtmlInputCheckBox ck = (WebUI.HtmlControls.HtmlInputCheckBox)ctl; ck.Checked = false; } else if (type == typeof(WebUI.HtmlControls.HtmlInputPassword))//密码域 { WebUI.HtmlControls.HtmlInputPassword ck = (WebUI.HtmlControls.HtmlInputPassword)ctl; ck.Value = ""; } #endregion } }
/// <summary> /// Set back the updated value from the dataset to each controls of the panel /// Also sets validation and javascript events on the controls. /// </summary> /// <param name="PanelControls"></param> /// <param name="datasetDocument"></param> public void SetControlValues(System.Web.UI.WebControls.Panel PanelControls, DataSet datasetDocument) { try { System.Web.UI.WebControls.HiddenField HiddenFieldValidation = new System.Web.UI.WebControls.HiddenField(); using (datasetDocument) { HiddenFieldValidation.ID = "HiddenFieldValidation"; PanelControls.Controls.Add(HiddenFieldValidation); System.Collections.IEnumerator eControls = PanelControls.Controls.GetEnumerator(); while (eControls.MoveNext()) { object objCurrentControl = eControls.Current; switch (objCurrentControl.GetType().ToString()) { case "System.Web.UI.HtmlControls.HtmlInputHidden": { System.Web.UI.HtmlControls.HtmlInputHidden hdnTemp = (System.Web.UI.HtmlControls.HtmlInputHidden)objCurrentControl; string primaryKey = hdnTemp.Attributes["PrimaryKey"]; if (!String.IsNullOrEmpty(primaryKey)) { string fieldName = hdnTemp.Attributes["FieldName"]; string tableName = hdnTemp.Attributes["TableName"]; if (CheckFieldValues(tableName, fieldName, datasetDocument)) { hdnTemp.Value = datasetDocument.Tables[tableName].Rows[0][fieldName].ToString(); } } break; } case "System.Web.UI.WebControls.TextBox": { System.Web.UI.WebControls.TextBox txtTemp = (System.Web.UI.WebControls.TextBox)objCurrentControl; txtTemp.Attributes.Add("OnChange", "isdirty()"); string fieldName = txtTemp.Attributes["FieldName"]; string tableName = txtTemp.Attributes["TableName"]; string validation = txtTemp.Attributes["Validate"]; if (!String.IsNullOrEmpty(validation)) { if (HiddenFieldValidation.Value == "") { HiddenFieldValidation.Value = txtTemp.ClientID; } else { HiddenFieldValidation.Value += ";" + txtTemp.ClientID; } } if (CheckFieldValues(tableName, fieldName, datasetDocument)) { txtTemp.Text = datasetDocument.Tables[tableName].Rows[0][fieldName].ToString(); } break; } case "System.Web.UI.WebControls.CheckBox": { System.Web.UI.WebControls.CheckBox chkTemp = (System.Web.UI.WebControls.CheckBox)objCurrentControl; chkTemp.Attributes.Add("OnClick", "isdirty()"); string fieldName = chkTemp.Attributes["FieldName"]; string tableName = chkTemp.Attributes["TableName"]; string validation = chkTemp.Attributes["Validate"]; if (!String.IsNullOrEmpty(validation)) { if (HiddenFieldValidation.Value == "") { HiddenFieldValidation.Value = chkTemp.ClientID; } else { HiddenFieldValidation.Value += ";" + chkTemp.ClientID; } } if (CheckFieldValues(tableName, fieldName, datasetDocument)) { chkTemp.Checked = datasetDocument.Tables[tableName].Rows[0][fieldName].ToString() == "Y" ? true : false; } break; } case "System.Web.UI.WebControls.DropDownList": { System.Web.UI.WebControls.DropDownList ddlTemp = (System.Web.UI.WebControls.DropDownList)objCurrentControl; ddlTemp.Attributes.Add("OnChange", "isdirty()"); string fieldName = ddlTemp.Attributes["FieldName"]; string tableName = ddlTemp.Attributes["TableName"]; string dataSource = ddlTemp.Attributes["DataSource"]; /////////No Need string SelectCase = ddlTemp.Attributes["SelectCase"]; string SelectType = ddlTemp.Attributes["SelectType"]; string dataTextField = ddlTemp.Attributes["TextField"]; string dataValueField = ddlTemp.Attributes["ValueField"]; string validation = ddlTemp.Attributes["Validate"]; if (!String.IsNullOrEmpty(validation)) { if (HiddenFieldValidation.Value == "") { HiddenFieldValidation.Value = ddlTemp.ClientID; } else { HiddenFieldValidation.Value += ";" + ddlTemp.ClientID; } } //FillDropDowns(ddlTemp, dataSource, dataTextField, dataValueField); FillDropDowns(ddlTemp, dataSource, dataTextField, dataValueField, SelectCase, SelectType); if (CheckFieldValues(tableName, fieldName, datasetDocument)) { ddlTemp.SelectedValue = datasetDocument.Tables[tableName].Rows[0][fieldName].ToString(); } break; } case "System.Web.UI.WebControls.RadioButton": { System.Web.UI.WebControls.RadioButton rbTemp = (System.Web.UI.WebControls.RadioButton)objCurrentControl; rbTemp.Attributes.Add("OnClick", "isdirty()"); string fieldName = rbTemp.Attributes["FieldName"]; string tableName = rbTemp.Attributes["TableName"]; string value = rbTemp.Attributes["Value"]; string validation = rbTemp.Attributes["Validate"]; if (!String.IsNullOrEmpty(validation)) { if (HiddenFieldValidation.Value == "") { HiddenFieldValidation.Value = rbTemp.ClientID; } else { HiddenFieldValidation.Value += ";" + rbTemp.ClientID; } } if (CheckFieldValues(tableName, fieldName, datasetDocument)) { if (datasetDocument.Tables[tableName].Rows[0][fieldName].ToString().Trim() == value.Trim()) { rbTemp.Checked = true; } } break; } } } } } catch (Exception ex) { throw (ex); } }
/// <summary> /// 填充表单 /// </summary> /// <param name="entity"></param> /// <param name="control"></param> public static void FillForm(WebUI.Control control, Object entity) { if (entity == null || control == null) { return; } PropertyInfo[] propertyList = entity.GetProperties(); foreach (PropertyInfo pi in propertyList) { WebUI.Control ctl = control.FindControl(string.Format(IdFormat, pi.Name)); if (ctl == null) { continue; } Type ctlType = ctl.GetType(); #region 处理服务器控件 if (ctlType == typeof(WebUI.WebControls.TextBox))//文本框 { if (entity.GetPropertyValue(pi.Name) != null) { ((WebUI.WebControls.TextBox)ctl).Text = entity.GetPropertyValue(pi.Name).ToString(); } } else if (ctlType == typeof(WebUI.WebControls.Image))//图片 { if (entity.GetPropertyValue(pi.Name) != null) { string imageUrl = entity.GetPropertyValue(pi.Name).ToString(); if (!string.IsNullOrEmpty(imageUrl)) { ((WebUI.WebControls.Image)ctl).ImageUrl = imageUrl; } } } else if (ctlType == typeof(WebUI.WebControls.DropDownList))//选择框 { if (entity.GetPropertyValue(pi.Name) != null) { ((WebUI.WebControls.DropDownList)ctl).SelectedValue = entity.GetPropertyValue(pi.Name).ToString(); } } else if (ctlType == typeof(WebUI.WebControls.HiddenField))//隐藏域 { if (entity.GetPropertyValue(pi.Name) != null) { ((WebUI.WebControls.HiddenField)ctl).Value = entity.GetPropertyValue(pi.Name).ToString(); } } else if (ctlType == typeof(WebUI.WebControls.RadioButton))//单选框 { WebUI.WebControls.RadioButton rb = (WebUI.WebControls.RadioButton)ctl; if (entity.GetPropertyValue(pi.Name) != null) { rb.Checked = entity.GetPropertyValue(pi.Name).ToString() == rb.Text ? true : false; } } else if (ctlType == typeof(WebUI.WebControls.CheckBox))//复选框 { WebUI.WebControls.CheckBox ck = (WebUI.WebControls.CheckBox)ctl; if (entity.GetPropertyValue(pi.Name) != null) { ck.Checked = entity.GetPropertyValue(pi.Name).ToString() == ck.Text ? true : false; } } else if (ctlType == typeof(WebUI.WebControls.CheckBoxList))//复选框列表 { WebUI.WebControls.CheckBoxList ck = (WebUI.WebControls.CheckBoxList)ctl; if (entity.GetPropertyValue(pi.Name) != null) { string sel = entity.GetPropertyValue(pi.Name).ToString(); foreach (WebUI.WebControls.ListItem li in ck.Items) { if (sel.IndexOf(",") > -1 && (sel.IndexOf(li.Value + ",") > -1 || sel.IndexOf("," + li.Value) > -1)) { li.Selected = true; } else if (sel.IndexOf(",") == -1 && sel == li.Value) { li.Selected = true; } else { li.Selected = false; } } } } else if (ctlType == typeof(WebUI.WebControls.RadioButtonList))//单框列表 { WebUI.WebControls.RadioButtonList ck = (WebUI.WebControls.RadioButtonList)ctl; if (entity.GetPropertyValue(pi.Name) != null) { ck.SelectedValue = entity.GetPropertyValue(pi.Name).ToString(); } } else if (ctlType == typeof(WebUI.WebControls.ListBox))//列表框 { WebUI.WebControls.ListBox ck = (WebUI.WebControls.ListBox)ctl; if (entity.GetPropertyValue(pi.Name) != null) { string sel = entity.GetPropertyValue(pi.Name).ToString(); foreach (WebUI.WebControls.ListItem li in ck.Items) { if (sel.IndexOf(",") > -1 && (sel.IndexOf(li.Value + ",") > -1 || sel.IndexOf("," + li.Value) > -1)) { li.Selected = true; } else if (sel.IndexOf(",") == -1 && sel == li.Value) { li.Selected = true; } else { li.Selected = false; } } } } #endregion #region 处理不同Html控件 else if (ctlType == typeof(WebUI.HtmlControls.HtmlInputText))//文本域 { WebUI.HtmlControls.HtmlInputText ct = (WebUI.HtmlControls.HtmlInputText)ctl; if (entity.GetPropertyValue(pi.Name) != null) { ct.Value = entity.GetPropertyValue(pi.Name).ToString(); } } else if (ctlType == typeof(WebUI.HtmlControls.HtmlTextArea))//文本域 { WebUI.HtmlControls.HtmlTextArea ct = (WebUI.HtmlControls.HtmlTextArea)ctl; if (entity.GetPropertyValue(pi.Name) != null) { ct.Value = entity.GetPropertyValue(pi.Name).ToString(); } } else if (ctlType == typeof(WebUI.HtmlControls.HtmlSelect))//选择域 { WebUI.HtmlControls.HtmlSelect ct = (WebUI.HtmlControls.HtmlSelect)ctl; if (entity.GetPropertyValue(pi.Name) != null) { for (int i = 0; i < ct.Items.Count; i++) { if (ct.Items[i].Value == entity.GetPropertyValue(pi.Name).ToString()) { ct.SelectedIndex = i; } } } } else if (ctlType == typeof(WebUI.HtmlControls.HtmlInputHidden))////隐藏域 { WebUI.HtmlControls.HtmlInputHidden ct = (WebUI.HtmlControls.HtmlInputHidden)ctl; if (entity.GetPropertyValue(pi.Name) != null) { ct.Value = entity.GetPropertyValue(pi.Name).ToString(); } } else if (ctlType == typeof(WebUI.HtmlControls.HtmlInputRadioButton))//单选域 { WebUI.HtmlControls.HtmlInputRadioButton rb = (WebUI.HtmlControls.HtmlInputRadioButton)ctl; if (rb.Checked && entity.GetPropertyValue(pi.Name) != null) { rb.Checked = entity.GetPropertyValue(pi.Name).ToString() == rb.Value ? true : false; } } else if (ctlType == typeof(WebUI.HtmlControls.HtmlInputCheckBox))//复选域 { WebUI.HtmlControls.HtmlInputCheckBox ck = (WebUI.HtmlControls.HtmlInputCheckBox)ctl; if (entity.GetPropertyValue(pi.Name) != null) { if (entity.GetPropertyValue(pi.Name).ToString().IndexOf("," + ck.Value) != -1) { ck.Checked = true; } } } else if (ctlType == typeof(WebUI.HtmlControls.HtmlInputPassword))//密码域 { WebUI.HtmlControls.HtmlInputPassword ck = (WebUI.HtmlControls.HtmlInputPassword)ctl; if (entity.GetPropertyValue(pi.Name) != null) { ck.Value = entity.GetPropertyValue(pi.Name).ToString(); } } #endregion } }