惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

C
CERT Recently Published Vulnerability Notes
S
Security @ Cisco Blogs
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Help Net Security
Help Net Security
Spread Privacy
Spread Privacy
WordPress大学
WordPress大学
S
Schneier on Security
博客园 - 聂微东
C
Cybersecurity and Infrastructure Security Agency CISA
F
Full Disclosure
人人都是产品经理
人人都是产品经理
Cisco Talos Blog
Cisco Talos Blog
D
Docker
aimingoo的专栏
aimingoo的专栏
Application and Cybersecurity Blog
Application and Cybersecurity Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
月光博客
月光博客
GbyAI
GbyAI
Stack Overflow Blog
Stack Overflow Blog
V
Visual Studio Blog
Security Latest
Security Latest
C
CXSECURITY Database RSS Feed - CXSecurity.com
N
News and Events Feed by Topic
小众软件
小众软件
A
About on SuperTechFans
Scott Helme
Scott Helme
Cloudbric
Cloudbric
T
Threatpost
雷峰网
雷峰网
NISL@THU
NISL@THU
N
News | PayPal Newsroom
Microsoft Azure Blog
Microsoft Azure Blog
T
Tailwind CSS Blog
T
Tor Project blog
T
The Blog of Author Tim Ferriss
The Hacker News
The Hacker News
C
Cyber Attacks, Cyber Crime and Cyber Security
量子位
Latest news
Latest news
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
I
Intezer
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
P
Privacy International News Feed
TaoSecurity Blog
TaoSecurity Blog
N
News and Events Feed by Topic
IT之家
IT之家
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
MongoDB | Blog
MongoDB | Blog
P
Privacy & Cybersecurity Law Blog

博客园 - LuckPanda

试图运行项目时出错:无法启动调试 & mdm.exe 伪装 病毒 安装程序检测到另一个程序要求计算机重新启动.必须重新启动计算机后才能安装visualstudio.net系统必备 尝试live writer写csdn/cnblogs日志 修复vs2003调试器 艾宾浩斯记忆曲线 vs2003和vs2005安装程序制作笔记 Using 未声明 使用线程加载控件,通过delegate创建控件,但仍报错“在某个线程上创建的控件不能成为在另一个线程上创建的控件的父级” winform不能用窗体设计器打开,只能用代码编辑器打开 crystal report(水晶报表) 在vista 下无法预览,与UAC(用户帐号控制)有关 给alimama的建议 十大常用杀毒软件试用 云计算最终会将软件变为免费 云计算淹没了虚拟主机业务 最近网站接连被攻击 SQL 注入 常用手法 Qq2007 正式版 登录协议分析之发报程序C#版本 qq 2007 正式版 协议 分析 91 62 ba dd 22 SharePoint 和 Reporting Service 的集成 今早发现 sharepoint 线程被终止 的提示
怎样在Sharepoint webpart中写 Repeat 、datalist 、datagrid ,读懂这段代码应该可以解决这类问题了
LuckPanda · 2006-07-17 · via 博客园 - LuckPanda

using System;
using System.ComponentModel;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml.Serialization;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.WebPartPages;
using System.Data;
using System.Data.SqlClient;
using Microsoft.ApplicationBlocks.Data;

namespace Sample.NewInfo
{
 /// <summary>
 /// Description for NewInformation.
 /// </summary>
 [DefaultProperty("Text"),
  ToolboxData("<{0}:NewInformation runat=server></{0}:NewInformation>"),
  XmlRoot(Namespace="NewInfo")]
 public class NewInformation : Microsoft.SharePoint.WebPartPages.WebPart
 {
  private const string defaultText = "";

  private string text = defaultText;
  protected System.Web.UI.WebControls.Repeater Repeater1;

  [Browsable(true),
   Category("Miscellaneous"),
   DefaultValue(defaultText),
   WebPartStorage(Storage.Personal),
   FriendlyName("Text"),
   Description("Text Property")]
  public string Text
  {
   get
   {
    return text;
   }

   set
   {
    text = value;
   }
  }
 


  protected override void CreateChildControls()
  {
   Repeater1=new Repeater();
   Repeater1.ItemTemplate=new RepiTemplate();
   try
   {
    string strConn = System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"];
    DataSet dsInfo = SqlHelper.ExecuteDataset(strConn,CommandType.Text,"SELECT TOP 10 * FROM NewInfo ORDER BY PublishDate DESC");
     
    Repeater1.DataSource=dsInfo;
    Repeater1.DataBind();
   }
   catch (Exception ex)
   {
    throw ex;
   }
   this.Controls.Add(Repeater1);
   base.CreateChildControls ();
  }

  /// <summary>
  /// Render this Web Part to the output parameter specified.
  /// </summary>
  /// <param name="output"> The HTML writer to write out to </param>
  protected override void RenderWebPart(HtmlTextWriter output)
  {

   output.Write("<div id='demo'  style='overflow:hidden;height:200;width:150;vertical-align:middle'><div id='demo1' style='vertical-align:middle'>");
   Repeater1.RenderControl(output);
   output.Write("</div><div id='demo2'  style='vertical-align:middle'></div></div>"); 
   output.Write(@"<script Language=Javascript>
      var speed=200;
      demo2.innerHTML=demo1.innerHTML
      function Marquee()
      {
      if(demo2.offsetTop-demo.scrollTop<=0)
      demo.scrollTop-=demo1.offsetHeight;
      else
      demo.scrollTop+=2;
      }
      var MyMar=setInterval(Marquee,speed)
      demo.onmouseover=function() {clearInterval(MyMar)}
      demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
      </script>");

  }
 }

 class RepiTemplate:ITemplate
 {
  public RepiTemplate(){}

  public void InstantiateIn(Control wc)
  {
   Literal l=new Literal();
   l.DataBinding+=new EventHandler(this.BindData);
   wc.Controls.Add(l);
  }
  public void BindData(object Sender,EventArgs e)
  {
   Literal l=(Literal)Sender;
   System.Web.UI.WebControls.RepeaterItem Con=(System.Web.UI.WebControls.RepeaterItem)l.NamingContainer;
   l.Text ="·<a href='"+((DataRowView)Con.DataItem)["URL"].ToString()+"'>"+((DataRowView)Con.DataItem)["Title"].ToString()+"</a><BR><BR>";
  }
 }

}