⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 config.cs

📁 ASP.NET简洁论坛源代码 这是一个简单的论坛
💻 CS
📖 第 1 页 / 共 5 页
字号:
		}
		/// <summary>
		/// RepeaterPageLoad控件分页程序,单击“最后一页”,所做的显示
		/// </summary>
		/// <param name="str_Sql">Select-SQL语句</param>
		/// <param name="lbl_PageMessage">每页信息,包括每页要显示记录数,总记录,当前页数,比如:[ 1 ] / [ 1 ], 总记录数:[ 1 ]</param>
		/// <param name="lnkbtn_First">linkbotton控件id值,单击后连接到第一页</param>
		/// <param name="lnkbtn_Prev">linkbotton控件id值,单击后连接到当前页的上一页</param>
		/// <param name="lnkbtn_Next">linkbotton控件id值,单击后连接到当前页的下一页</param>
		/// <param name="lnkbtn_Last">linkbotton控件id值,单击后连接到最后一页</param>
		/// <param name="myRepeater">Repeater控件id值</param>
		public void RepeaterPageLast(string str_Sql,Label lbl_Pagesize,Label lbl_PageMessage,LinkButton lnkbtn_First,LinkButton lnkbtn_Prev,LinkButton lnkbtn_Next,LinkButton lnkbtn_Last,Repeater myRepeater)
		{
			ds=new DataSet();
			SqlDataAdapter myAdapter1=new SqlDataAdapter(str_Sql,myConnection);
			int int_RecordCount=int.Parse(GetTwoMiddleLastStr(lbl_PageMessage.Text,"[","]")); // 获得总记录数
			int int_PageCount=int.Parse(GetTwoMiddleFirstStr(GetLastStr(lbl_PageMessage.Text,"/"),"[","]")); // 获得总页数
			int CurrentPage=int_PageCount; // 当前的页数
			int startRecord = (CurrentPage-1)*int.Parse(lbl_Pagesize.Text);  
			lbl_PageMessage.Text="[ "+CurrentPage.ToString()+" ] / [ "+int_PageCount.ToString()+" ], 总记录数:[ "+int_RecordCount.ToString()+" ]";// 获得页信息
			myAdapter1.Fill(ds,startRecord,int.Parse(lbl_Pagesize.Text),"news");
			myRepeater.DataSource=ds.Tables["news"].DefaultView;
			myRepeater.DataBind();
			if (CurrentPage==1)
			{
				lnkbtn_First.Enabled=false;
				lnkbtn_Prev.Enabled=false;
			}
			else
			{
				lnkbtn_First.Enabled=true;
				lnkbtn_Prev.Enabled=true;
			}
			if (int_PageCount==CurrentPage)
			{
				lnkbtn_Next.Enabled=false;
				lnkbtn_Last.Enabled=false;
			}
			else
			{
				lnkbtn_Next.Enabled=true;
				lnkbtn_Last.Enabled=true;
			}
		}
		/// <summary>
		/// 绑定DropDownList控件并显示数据,DropDownList控件Value,Text值将等于str_Text值
		/// </summary>
		/// <param name="str_Text">绑定DropDownList控件Value,Text值相对应数据库表字段名</param>
		/// <param name="sql">Select-SQL语句</param>
		/// <param name="myDropDownList">DropDownList控件id值</param>
		public void BindDropDownList(string str_Text,string sql,DropDownList myDropDownList)
		{
			// 绑定DropDownList控件(注:四个函数,该函数需要一个字段名,分别绑定Value和Text两值,默认表名)
			Open();
			Fill(sql);
			myDropDownList.DataSource=ds.Tables[0].DefaultView;
			myDropDownList.DataValueField =str_Text;
			myDropDownList.DataTextField=str_Text;
			myDropDownList.DataBind();
		}
		/// <summary>
		/// 绑定DropDownList控件并显示数据,DropDownList控件Value,Text值将分别等于等于str_Value,str_Text值
		/// </summary>
		/// <param name="str_Value">绑定DropDownList控件Value值相对应数据库表字段名</param>
		/// <param name="str_Text">绑定DropDownList控件Text值相对应数据库表字段名</param>
		/// <param name="sql">Select-SQL语句</param>
		/// <param name="myDropDownList">DropDownList控件id值</param>
		public void BindDropDownList(string str_Value,string str_Text,string sql,DropDownList myDropDownList)
		{
			Open();
			Fill(sql);
			myDropDownList.DataSource=ds.Tables[0].DefaultView;
			myDropDownList.DataValueField =str_Value;
			myDropDownList.DataTextField=str_Text;
			myDropDownList.DataBind();
		}
		public void SelectdropDownListValue(string str_Value_Field,DropDownList myDropDownList)
		{
			myDropDownList.Items[0].Selected=false;
			for (int i=0;i<myDropDownList.Items.Count;i++) 
			{
				if (str_Value_Field==myDropDownList.Items[i].Value)
				{
					myDropDownList.Items[i].Selected=true;
					break;
				}
			}
		}
		public void SelectdropDownListText(string str_Text_Field,DropDownList myDropDownList)
		{
			myDropDownList.Items[0].Selected=false;
			for (int i=0;i<myDropDownList.Items.Count;i++) 
			{
				if (str_Text_Field==myDropDownList.Items[i].Value)
				{
					myDropDownList.Items[i].Selected=true;
					break;
				}
			}
		}
		/// <summary>
		/// 绑定DropDownList控件,取得选中值
		/// </summary>
		/// <param name="str_Value">数据库表示Value值字段</param>
		/// <param name="str_Text">数据库表示Text值字段</param>
		/// <param name="str_Value_Field"></param>
		/// <param name="str_Sql"></param>
		/// <param name="myDropDownList"></param>
		public void SelectBindDropDownListValue(string str_Value,string str_Text,string str_Value_Field,string str_Sql,DropDownList myDropDownList)
		{
			BindDropDownList(str_Value,str_Text,str_Sql,myDropDownList);// 绑定myDropDownList控件
			myDropDownList.Items[0].Selected=false;
			for (int i=0;i<myDropDownList.Items.Count;i++) 
			{
				if (str_Value_Field==myDropDownList.Items[i].Value)
				{
					myDropDownList.Items[i].Selected=true;
					break;
				}
			}
		}
		public void SelectBindDropDownListText(string str_Value,string str_Text,string str_Text_Field,string str_Sql,DropDownList myDropDownList)
		{
			BindDropDownList(str_Value,str_Text,str_Sql,myDropDownList);// 绑定myDropDownList控件
			myDropDownList.Items[0].Selected=false;
			for (int i=0;i<myDropDownList.Items.Count;i++) 
			{
				if (str_Text_Field==myDropDownList.Items[i].Text)
				{
					myDropDownList.Items[i].Selected=true;
					break;
				}
			}
		}
		/// <summary>
		/// 绑定CheckBoxList控件并显示数据,CheckBoxList控件Value,Text值将等于str_Text值
		/// </summary>
		/// <param name="str_Text">绑定CheckBoxList控件Value,Text值相对应数据库表字段名</param>
		/// <param name="sql">Select-SQL语句</param>
		/// <param name="myCheckBoxList">CheckBoxList控件id值</param>
		public void BindCheckBoxList(string str_Text,string sql,CheckBoxList myCheckBoxList)
		{
			Fill(sql);
			myCheckBoxList.DataSource=ds.Tables[0].DefaultView;
			myCheckBoxList.DataValueField =str_Text;
			myCheckBoxList.DataTextField=str_Text;
			myCheckBoxList.DataBind();
			ds.Clear();
			myConnection.Close();
		}
		/// <summary>
		/// 绑定CheckBoxList控件并显示数据,CheckBoxList控件Value,Text值将分别等于等于str_Value,str_Text值
		/// </summary>
		/// <param name="str_Value">绑定CheckBoxList控件Value值相对应数据库表字段名</param>
		/// <param name="str_Text">绑定CheckBoxList控件Text值相对应数据库表字段名</param>
		/// <param name="sql">Select-SQL语句</param>
		/// <param name="myCheckBoxList">CheckBoxList控件id值</param>
		public void BindCheckBoxList(string str_Value,string str_Text,string sql,CheckBoxList myCheckBoxList)
		{
			Fill(sql);
			myCheckBoxList.DataSource=ds.Tables[0].DefaultView;
			myCheckBoxList.DataValueField =str_Value;
			myCheckBoxList.DataTextField=str_Text;
			myCheckBoxList.DataBind();
			ds.Clear();
			myConnection.Close();
		}
		public void SelectBindCheckBoxListValue(string str_Value,string str_Text,string str_Value_Field,string str_Sql,CheckBoxList myDropDownList)
		{
			BindCheckBoxList(str_Value,str_Text,str_Sql,myDropDownList);// 绑定myDropDownList控件
			for (int i=0;i<myDropDownList.Items.Count;i++) 
			{
				if (str_Value_Field.IndexOf(myDropDownList.Items[i].Value)!=-1)
				{
					myDropDownList.Items[i].Selected=true;
				}
			}
		}
		public void SelectBindCheckBoxListText(string str_Value,string str_Text,string str_Text_Field,string str_Sql,CheckBoxList myDropDownList)
		{
			BindCheckBoxList(str_Value,str_Text,str_Sql,myDropDownList);// 绑定myDropDownList控件
			for (int i=0;i<myDropDownList.Items.Count;i++) 
			{
				if (str_Text_Field.IndexOf(myDropDownList.Items[i].Value)!=-1)
				{
					myDropDownList.Items[i].Selected=true;
				}
			}
		}
		/// <summary>
		/// 绑定RadioButtonList控件并显示数据,RadioButtonList控件Value,Text值将等于str_Text值
		/// </summary>
		/// <param name="str_Text">绑定RadioButtonList控件Value,Text值相对应数据库表字段名</param>
		/// <param name="sql">Select-SQL语句</param>
		/// <param name="myRadioButtonList">RadioButtonList控件id值</param>
		public void BindRadioButtonList(string str_Text,string sql,RadioButtonList myRadioButtonList)
		{
			Fill(sql);
			myRadioButtonList.DataSource=ds.Tables[0].DefaultView;
			myRadioButtonList.DataValueField =str_Text;
			myRadioButtonList.DataTextField=str_Text;
			myRadioButtonList.DataBind();
			myConnection.Close();
		}
		/// <summary>
		/// 绑定RadioButtonList控件并显示数据,RadioButtonList控件Value,Text值将分别等于等于str_Value,str_Text值
		/// </summary>
		/// <param name="str_Value">绑定RadioButtonList控件Value值相对应数据库表字段名</param>
		/// <param name="str_Text">绑定RadioButtonList控件Text值相对应数据库表字段名</param>
		/// <param name="sql">Select-SQL语句</param>
		/// <param name="myRadioButtonList">RadioButtonList控件id值</param>
		public void BindRadioButtonList(string str_Value,string str_Text,string sql,RadioButtonList myRadioButtonList)
		{
			// 绑定DropDownList控件(注:四个函数,该函数需要两个字段名,分别绑定Value和Text两值,默认表名)
			Fill(sql);
			myRadioButtonList.DataSource=ds.Tables[0].DefaultView;
			myRadioButtonList.DataValueField =str_Value;
			myRadioButtonList.DataTextField=str_Text;
			myRadioButtonList.DataBind();
			myConnection.Close();
		}
		public void SelectRadioButtonList(string str_Value,string str_Text,string str_Field,string str_Sql,RadioButtonList myRadioButtonList)
		{
			BindRadioButtonList(str_Value,str_Text,str_Sql,myRadioButtonList);// 绑定myDropDownList控件
			
			for (int i=0;i<myRadioButtonList.Items.Count;i++) 
			{
				myRadioButtonList.Items[i].Selected=false;
				if (str_Field==myRadioButtonList.Items[i].Value)
				{
					myRadioButtonList.Items[i].Selected=true;
					break;
				}
			}
		}
		public void SelectRadioButtonList(string str_Text,string str_Field,string str_Sql,RadioButtonList myRadioButtonList)
		{
			BindRadioButtonList(str_Text,str_Sql,myRadioButtonList);// 绑定myDropDownList控件
			
			for (int i=0;i<myRadioButtonList.Items.Count;i++) 
			{
				myRadioButtonList.Items[i].Selected=false;
				if (str_Field==myRadioButtonList.Items[i].Text)
				{
					myRadioButtonList.Items[i].Selected=true;
					break;
				}
			}
		}



		/// <summary>
		/// 重载1:绑定树控件并显示——>节点没有连接,没有必要传递参数,适合后台维护
		/// </summary>
		/// <param name="f_key">数据库表关键字key值名</param>
		/// <param name="f_parentkey">数据库表保存父节点id值字段名</param>
		/// <param name="f_text">节点显示文字树数据库表字段名</param>
		/// <param name="str_Sql">Select-SQL语句</param>
		/// <param name="TreeView1">TreeView控件id值</param>
		public void  BindTreeView0(string f_key,string f_parentkey,string f_text,string str_Sql,Label lbl_Curnodeid,TreeView TreeView1)
		{
			GetTable(str_Sql); // 获得树的内存表
			TreeView1.Nodes.Clear(); // 清空树
			TreeNode rootnode=new TreeNode();
			rootnode.Text=dt.Rows[0][f_text].ToString(); // 给节点绑定显示值
			rootnode.NodeData=dt.Rows[0][f_key].ToString(); // 给节点绑定key值
			lbl_Curnodeid.Text=dt.Rows[0][f_key].ToString(); // 保存选中key值
			rootnode.Expanded=true; // 默认根结点为展开
			TreeView1.Nodes.Add(rootnode);
			string parentid=dt.Rows[0][f_parentkey].ToString()+dt.Rows[0][f_key].ToString()+"_"; // 他子节点的parentid字段值
			CreateNode0(f_key,f_parentkey,f_text,parentid,rootnode);// 加入所有根结点以下的结点 												
		}
		/// <summary>
		/// 重载1:遍历子节点——>节点没有连接,没有必要传递参数,适合后台维护
		/// </summary>
		/// <param name="f_key">数据库表关键字key值名</param>
		/// <param name="f_parentkey">数据库表保存父节点id值字段名</param>
		/// <param name="f_text">节点显示文字树数据库表字段名</param>
		/// <param name="str_Sql">Select-SQL语句</param>
		/// <param name="TreeView1">TreeView控件id值</param>
		public void CreateNode0(string f_key,string f_parentkey,string f_text,string parentid,TreeNode parentnode)
		{
			DataRow [] drs = dt.Select(f_parentkey +"= '" + parentid + "'");// 选出所有子节点
			foreach( DataRow r in drs )
			{
				TreeNode tempnode = new TreeNode();
				tempnode.Text = r[f_text].ToString();
				tempnode.NodeData = r[f_key].ToString();
				tempnode.Expanded=true;
				parentnode.Nodes.Add(tempnode);
				parentid=r[f_parentkey].ToString()+r[f_key].ToString()+"_";
				CreateNode0(f_key,f_parentkey,f_text,parentid,tempnode);
			}
		}


		

		/// <summary>
		/// 重载2:绑定树控件并显示——>节点有连接,连接传递一个参数,传递的参数是location
		/// </summary>
		/// <param name="f_key">数据库表关键字key值名</param>
		/// <param name="f_parentkey">数据库表保存父节点id值字段名</param>
		/// <param name="f_text">节点显示文字树数据库表字段名</param>
		/// <param name="str_Sql">Select-SQL语句</param>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -