Example #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     string catID = "";
     if (Settings["Nguon"] != null)
         try
         {
             Int32.Parse(Settings["Nguon"].ToString());
             catID = Settings["Nguon"].ToString();
         }
         catch { }
     if (catID != "") catID = "and N.catid=" + catID;
     int maxNews = 5;
     if (Settings["Trang"] != null)
         try
         {
             maxNews = Int32.Parse(Settings["Trang"].ToString());
         }
         catch { }
     string cmdTxt = string.Format(@"select top {0}
         ID, Headline, N.Description, ImageUrl, CONVERT(CHAR(11), CreatedDate, 103)+CONVERT(CHAR(5), CreatedDate, 108) AS Date, DesktopViewID, CatName 
         from news_news N
         join news_category C
         on N.catid=C.catid
         where N.published=1 {1}
         order by createddate desc", maxNews, catID);
     // Thực thi T-SQL đã nhập
     if (Settings["Nguon"].ToString() == "SQL" && Settings["SQL"] != null) cmdTxt = Settings["SQL"].ToString();
     DataSet ds;
     zClass ob = new zClass();
     catID = ob.zSelectNone(cmdTxt, out ds);
     try
     {
         DataColumn dc = new DataColumn("Link");
         ds.Tables[0].Columns.Add(dc);
         ds.Tables[0].AcceptChanges();
         foreach (DataRow dr in ds.Tables[0].Rows)
         {
             dr.BeginEdit();
             dr["Link"] = DotNetNuke.Common.Globals.NavigateURL(Convert.ToInt32(dr[5].ToString()), "", "id/" + dr[0].ToString());
             dr.EndEdit();
         }
         lbCatName.Text = ds.Tables[0].Rows[0][6].ToString();
         gvCatList.DataSource = ds;
         gvCatList.DataBind();
     }
     catch { }
 }