How to Create a listview ItemTenplate with c# not

MeChecksV 2008-05-03 09:14:27
RT

I am using vs2008 c# net3.5
Listview web control
...全文
213 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
MeChecksV 2008-05-03
  • 打赏
  • 举报
回复
TO SHOW DYNAMIC COLUMN
MeChecksV 2008-05-03
  • 打赏
  • 举报
回复
i just want to use listview control
崔鹏飞 2008-05-03
  • 打赏
  • 举报
回复
what do you wanna do?
To show the data?
why do you wanna do it throug such an ancient way?
May be gridview can help you
(it sucks,my e language)
MeChecksV 2008-05-03
  • 打赏
  • 举报
回复
Is there anyone can help me??
I read this article
http://msdn.microsoft.com/en-us/library/0e39s2ck.aspx

but i don't know how to bind then data in ItemTemplate

MY CODE;

public partial class DynamicList : System.Web.UI.Page
{

static void Item_DataBinding(object sender, System.EventArgs e)
{
PlaceHolder ph = (PlaceHolder)sender;
ListViewItem ri = (ListViewItem)ph.NamingContainer;
String UserIDValue = (String)DataBinder.Eval(ri.DataItem, "UserID");
String UserNameValue = (String)DataBinder.Eval(ri.DataItem, "UserName");
String GroupIDValue = (String)DataBinder.Eval(ri.DataItem, "GroupID");
((Label)ph.FindControl("UserID")).Text = UserIDValue.ToString();
((Label)ph.FindControl("UserName")).Text = UserNameValue.ToString();
((Label)ph.FindControl("GroupID")).Text = GroupIDValue.ToString();
}

protected void Page_Load(object sender, EventArgs e)
{
ListView1.AlternatingItemTemplate = new TempLate("AlternatingItemTemplate");
// ListView1.LayoutTemplate = new TempLate("LayoutTemplate");
ListView1.EmptyDataTemplate = new TempLate("EmptyDataTemplate");
ListView1.ItemTemplate = new TempLate("ItemTemplate");
DataSet ResultSet = RunQuery("Select * From UserInfo");
ListView1.DataSource = ResultSet;
ListView1.DataBind();

}
DataSet RunQuery(String QueryString)
{

// Declare the connection string. This example uses Microsoft SQL Server
// and connects to the Northwind sample database.
String ConnectionString = "Data Source=XU-AE42BC5C42AC;Initial Catalog=uzone;Persist Security Info=True;User ID=sa;Password=sa";

SqlConnection DBConnection = new SqlConnection(ConnectionString);
SqlDataAdapter DBAdapter;
DataSet ResultsDataSet = new DataSet();

try
{

// Run the query and create a DataSet.
DBAdapter = new SqlDataAdapter(QueryString, DBConnection);
DBAdapter.Fill(ResultsDataSet);

// Close the database connection.
DBConnection.Close();

}
catch (Exception ex)
{

// Close the database connection if it is still open.
if (DBConnection.State == ConnectionState.Open)
{
DBConnection.Close();
}

Message.Text = "Unable to connect to the database.";

}

return ResultsDataSet;

}

public class TempLate : ITemplate
{
private string templateType = "";
public TempLate(string type)
{
this.templateType = type;
}

//region ITemplate Members

public void InstantiateIn(Control container)
{
PlaceHolder ph = new PlaceHolder();
PlaceHolder itemPlaceholder = new PlaceHolder();
itemPlaceholder.ID = "itemPlaceholder";

Label UserIDLabel = new Label();
Label UserNameLabel = new Label();
Label GroupIDLabel = new Label();
UserIDLabel.ID = "UserIDLabel";
UserIDLabel.Text = "test";
UserNameLabel.ID = "UserNameLabel";
GroupIDLabel.ID = "GroupIDLabel";
switch (this.templateType)
{
case "AlternatingItemTemplate":
ph.Controls.Add(new LiteralControl("<tr><td>"));
ph.Controls.Add(UserIDLabel);
ph.Controls.Add(new LiteralControl("</td><td>"));
ph.Controls.Add(UserNameLabel);
ph.Controls.Add(new LiteralControl("</td><td>"));
ph.Controls.Add(GroupIDLabel);
ph.Controls.Add(new LiteralControl("</td></tr>"));
break;
case "LayoutTemplate":
ph.Controls.Add(new LiteralControl("<table runat=\"server\">"));
ph.Controls.Add(new LiteralControl("<tr runat=\"server\">"));
ph.Controls.Add(new LiteralControl("<td runat=\"server\">"));
ph.Controls.Add(new LiteralControl("<tr runat=\"server\">"));
ph.Controls.Add(new LiteralControl("<table ID=\"itemPlaceholderContainer\" runat=\"server\" border=\"1\">"));
ph.Controls.Add(new LiteralControl("<tr runat=\"server\">"));
ph.Controls.Add(new LiteralControl("<th runat=\"server\">UserID</th>"));
ph.Controls.Add(new LiteralControl("<th runat=\"server\">UserName</th>"));
ph.Controls.Add(new LiteralControl("<th runat=\"server\">GroupID</th></tr>"));
ph.Controls.Add(new LiteralControl("<tr ID=\"itemPlaceholder\" runat=\"server\"></tr>"));
ph.Controls.Add(new LiteralControl("</table></td></tr>"));
break;

case "EmptyDataTemplate":
ph.Controls.Add(new LiteralControl("<tr></tr>"));
break;
case "ItemTemplate":
ph.Controls.Add(new LiteralControl("<tr><td>"));
ph.Controls.Add(UserIDLabel);
ph.Controls.Add(new LiteralControl("</td><td>"));
ph.Controls.Add(UserNameLabel);
ph.Controls.Add(new LiteralControl("</td><td>"));
ph.Controls.Add(GroupIDLabel);
ph.Controls.Add(new LiteralControl("</td></tr>"));
ph.DataBinding += new EventHandler(Item_DataBinding);
break;



}

}



//endregion
}
Pig23 2008-05-03
  • 打赏
  • 举报
回复
what the hell language?
内容概要:本文系统介绍了TVP-SV-FAVAR(时变参数-随机波动率-因子增广向量自回归)模型的理论基础与Matlab代码实现方法,重点围绕其在处理高维时间序列数据中时变特征、随机波动率及潜在公共因子的能力展开。文章详细解析了模型的核心构成,包括因子提取、时变参数设定、随机波动率建模以及基于贝叶斯框架的参数估计流程,并配套提供完整的Matlab程序代码与实证案例演示,帮助读者理解并复现该复杂计量经济模型的实际应用过程。; 适合人群:具备扎实计量经济学背景和一定Matlab编程能力的研究生、高校科研人员及金融机构量化分析师,尤其适用于从事宏观经济建模、货币政策评估、系统性风险测度等方向的研究工作者。; 使用场景及目标:①深入掌握TVP-SV-FAVAR模型的建模逻辑与算法实现细节;②将其应用于宏观经济变量间的动态关联分析、政策冲击效应评估及不确定性传导机制研究;③复现国际顶级期刊(如AER、JME)中的相关实证研究,提升学术论文撰写与科研创新能力; 阅读建议:建议读者结合文中提供的Matlab代码逐模块调试运行,辅以经典文献深化对先验设定、MCMC采样及结果解读的理解,同时鼓励将模型拓展至其他领域(如金融市场、区域经济)进行创新性实证研究。

62,269

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧