您目前尚未登陆,请选择【登陆】或【注册
首页->其他源码->商务维基网源码>>Default.aspx.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:商务维基网源码
当前文件:文件类型 MerchantViki/Default.aspx.cs打开代码结构图
普通视图
		            
1using System; 2using System.Data; 3using System.Data.SqlClient; 4using System.Configuration; 5using System.Collections; 6using System.Web; 7using System.Web.Security; 8using System.Web.UI; 9using System.Web.UI.WebControls; 10using System.Web.UI.WebControls.WebParts; 11using System.Web.UI.HtmlControls; 12//该源码下载自www.51aspx.com(51aspx.com) 13 14public partial class _Default : System.Web.UI.Page 15{ 16 protected void Page_Load(object sender, EventArgs e) 17 { 18 this.Header.Title = Application.Get("siteName") + "---" + this.Header.Title; 19 20 if (!Page.IsPostBack) 21 { 22 BindData(); 23 if (Session["userName"] != null) 24 { 25 userInfoLbl.Text = "欢迎您:" + Session["userName"].ToString(); 26 if (Session["userPoint"] != null) 27 userInfoLbl.Text += "<br />积分:" + Session["userPoint"].ToString(); 28 } 29 else 30 { 31 userInfoLbl.Text = "当前用户为游客。"; 32 } 33 34 timeInfoLbl.Text = "今天是" + DateTime.Today.Year.ToString() + "" + DateTime.Today.Month.ToString() + "" + DateTime.Today.Day.ToString() + ""; 35 //timeInfoLbl.Text = "今天是" + DateTime.Now.ToShortDateString(); 36 } 37 } 38 39 private void BindData() 40 { 41 try 42 { 43 string conStr = Application.Get("conStr").ToString(); 44 SqlConnection sqlCon = new SqlConnection(conStr); 45 46 string cmdStr = null; 47 SqlCommand sqlCmd = new SqlCommand(); 48 SqlDataReader sqlDR; 49 50 sqlCon.Open(); 51 cmdStr = "select name,id from edition where isOpen = '是'"; 52 sqlCmd.CommandText = cmdStr; 53 sqlCmd.Connection = sqlCon; 54 sqlDR = sqlCmd.ExecuteReader(); 55 56 openEdList.DataSource = sqlDR; 57 openEdList.DataTextField = "name"; 58 openEdList.DataValueField = "id"; 59 openEdList.DataBind(); 60 61 sqlDR.Close(); 62 63 cmdStr = "select name,id from edition where isOpen = '否'"; 64 sqlCmd.CommandText = cmdStr; 65 sqlCmd.Connection = sqlCon; 66 sqlDR = sqlCmd.ExecuteReader(); 67 68 privateEdList.DataSource = sqlDR; 69 privateEdList.DataTextField = "name"; 70 privateEdList.DataValueField = "id"; 71 privateEdList.DataBind(); 72 73 sqlDR.Close(); 74 75 cmdStr = "select top 10 id,name,articleNum,click,createTime from edition where isopen='是' order by click desc "; 76 SqlDataAdapter sqlDA = new SqlDataAdapter(cmdStr, sqlCon); 77 DataSet ds = new DataSet(); 78 79 sqlDA.Fill(ds, "edition"); 80 81 DataGrid1.DataSource = ds.Tables["edition"].DefaultView; 82 83 DataGrid1.DataBind(); 84 85 //sqlDR.Close(); 86 sqlCon.Close(); 87 infoLbl.Text += "数据绑定成功。"; 88 } 89 catch (Exception ex) 90 { 91 //Response.Write("<script>alert('操纵错误:" + ex.Message + "');</script>"); 92 //throw new Exception(ex.Message, ex); 93 infoLbl.Text += ex.Message; 94 } 95 } 96 97 public void openEdBtn_Click(object sender, EventArgs e) 98 { 99 infoLbl.Text = openEdList.SelectedValue; 100 Response.Redirect("articleList.aspx?EditionID="+ openEdList.SelectedValue +"", false); 101 } 102 103 public void privateEdBtn_Click(object sender, EventArgs e) 104 { 105 infoLbl.Text = privateEdList.SelectedValue; 106 Response.Redirect("articleList.aspx?EditionID=" + privateEdList.SelectedValue + "", true); 107 } 108} 109
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:商务维基网源码
51Aspx.com 版权所有 CopyRight © 2000-2008. 京ICP备06046876号