gpt4 book ai didi

c# - 将表中的数据绑定(bind)到前端的转发器

转载 作者:行者123 更新时间:2023-11-28 08:29:00 26 4
gpt4 key购买 nike

我有一个表,我想将表中的数据绑定(bind)到转发器中。但是我无法开始如何获得它。这是我的设计 HTML。我需要它在中继器中。

我想显示类似 this 的内容

我的 HTML 如下所示:-

<div class="Newsdivalign">
<div id="testMsg" class="popup">
<div class="popup-container">
<div class="popup-content">
<div class="popup-close js-popup-close modal-close">X</div>
<div>
<p class="popup-para">Recognised by the World Economic Forum as a Global Growth Company, 2014</p>
</div>
<div style="padding: 7px;">
<p class="NewsDate">News Posted: Jan 15, 2015 – 05:08 PM EST</p>
<p class="SStorypara">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been
the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley
of type and scrambled it to make a type specimen book. It has survived not only five centuries, but
also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in
the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more
recently with desktop publishing software like Aldus PageMaker including versions of Lorem
Ipsum.
</p>
<p class="SStorypara">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been
the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley
of type and scrambled it to make a type specimen book. It has survived not only five centuries, but
also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in
the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more
recently with desktop publishing software like Aldus PageMaker including versions of Lorem
Ipsum.
</p>
<p class="SStorypara">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been
the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley
of type and scrambled it to make a type specimen book. It has survived not only five centuries, but
also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in
the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more
recently with desktop publishing software like Aldus PageMaker including versions of Lorem
Ipsum.
</p>
<p class="SStorypara">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been
the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley
of type and scrambled it to make a type specimen book. It has survived not only five centuries, but
also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in
the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more
recently with desktop publishing software like Aldus PageMaker including versions of Lorem
Ipsum.
</p>
</div>

</div>
</div>





</div>
<div class="Newsdiv">
<p class="Newspara"><a href="#testMsg" class="modal-popup">Recognised by the World Economic Forum as a Global Growth Company, 2014</a></p>
<p class="NewsDate">News Posted: Jan 15, 2015 – 05:08 PM EST &nbsp;&nbsp;&nbsp;<span class="label">NGO1</span>&nbsp;<span class="label">NGO1</span> </p>
<p class="NewsDate1"><a href="#">Click here</a> to know more</p>
</div>


<div class="Newsdiv">
<p class="Newspara"><a href="Div1">Recognised by the World Economic Forum as a Global Growth Company, 2014</a></p>
<p class="NewsDate">News Posted: Jan 15, 2015 – 05:08 PM EST &nbsp;&nbsp;&nbsp;<span class="label">NGO1</span></p>
<p class="NewsDate1"><a href="#">Click here</a> to know more </p>
</div>
<div class="Newsdiv">
<p class="Newspara"><a href="#">Recognised by the World Economic Forum as a Global Growth Company, 2014</a></p>
<p class="NewsDate">News Posted: Jan 15, 2015 – 05:08 PM EST &nbsp;&nbsp;&nbsp;<span class="label">NGO1</span>&nbsp;<span class="label">NGO1</span></p>
<p class="NewsDate1"><a href="#">Click here</a> to know more</p>
</div>
<div class="Newsdiv">
<p class="Newspara"><a href="#">Recognised by the World Economic Forum as a Global Growth Company, 2014</a></p>
<p class="NewsDate">News Posted: Jan 15, 2015 – 05:08 PM EST &nbsp;&nbsp;&nbsp;<span class="label">NGO1</span></p>
<p class="NewsDate1"><a href="#">Click here</a> to know more</p>
</div>
<div class="Newsdiv">
<p class="Newspara"><a href="#">Recognised by the World Economic Forum as a Global Growth Company, 2014</a></p>
<p class="NewsDate">News Posted: Jan 15, 2015 – 05:08 PM EST &nbsp;&nbsp;&nbsp;<span class="label">NGO1</span>&nbsp;<span class="label">NGO1</span></p>
<p class="NewsDate1"><a href="#">Click here</a> to know more</p>
</div>
<div class="Newsdiv">
<p class="Newspara"><a href="#">Recognised by the World Economic Forum as a Global Growth Company, 2014</a></p>
<p class="NewsDate">News Posted: Jan 15, 2015 – 05:08 PM EST &nbsp;&nbsp;&nbsp;<span class="label">NGO1</span></p>
<p class="NewsDate1"><a href="#">Click here</a> to know more</p>
</div>
<div class="Newsdiv">
<p class="Newspara"><a href="#">Recognised by the World Economic Forum as a Global Growth Company, 2014</a></p>
<p class="NewsDate">News Posted: Jan 15, 2015 – 05:08 PM EST &nbsp;&nbsp;&nbsp;<span class="label">NGO1</span>&nbsp;<span class="label">NGO1</span></p>
<p class="NewsDate1"><a href="#">Click here</a> to know more</p>
</div>
<div class="Newsdiv">
<p class="Newspara"><a href="#">Recognised by the World Economic Forum as a Global Growth Company, 2014</a></p>
<p class="NewsDate">News Posted: Jan 15, 2015 – 05:08 PM EST &nbsp;&nbsp;&nbsp;<span class="label">NGO1</span></p>
<p class="NewsDate1"><a href="#">Click here</a> to know more</p>
</div>
<div class="Newsdiv">
<p class="Newspara"><a href="#">Recognised by the World Economic Forum as a Global Growth Company, 2014</a></p>
<p class="NewsDate">News Posted: Jan 15, 2015 – 05:08 PM EST &nbsp;&nbsp;&nbsp;<span class="label">NGO1</span>&nbsp;<span class="label">NGO1</span></p>
<p class="NewsDate1"><a href="#">Click here</a> to know more</p>
</div>
<div class="Newsdiv">
<p class="Newspara"><a href="#">Recognised by the World Economic Forum as a Global Growth Company, 2014</a></p>
<p class="NewsDate">News Posted: Jan 15, 2015 – 05:08 PM EST &nbsp;&nbsp;&nbsp;<span class="label">NGO1</span>&nbsp;<span class="label">NGO1</span></p>
<p class="NewsDate1"><a href="#">Click here</a> to know more</p>
</div>
<div class="pagination clearfix">
<a href="#">First</a>
&nbsp;<a href="#">«</a>

<a href="#">1</a>
<strong>2</strong>
<a href="#">3</a>

<a href="#">»</a>
&nbsp;<a href="#">Last</a>
</div>

</div>

请帮忙

我的更新代码:-

<asp:Repeater ID="rptNews" runat="server">
<ItemTemplate>
<div class="Newsdiv">
<p class="Newspara"><a href="#"><%#Eval("title")%></a></p>
<p class="NewsDate1"><a href="#">Click here</a> to know more</p>
</div>
</ItemTemplate>
</asp:Repeater>

代码隐藏:-

public void bindRepeater()
{
DataTable dtInfo = new DataTable();
dtInfo.Columns.Add("title");
DataRow dr;
for (int i = 0; i < 5; i++)
{
dr = dtInfo.NewRow();
dr["title"] = DateTime.Now.ToShortDateString();
dtInfo.Rows.Add(dr);

}
}

最佳答案

试试这个。将这个中继器放在您的设计中。

 <asp:Repeater ID="rptNews" runat="server">
<ItemTemplate>
<div class="Newsdiv">
<p class="Newspara"><a href="#"><%#Eval("News_Title")%></a></p>
<p class="NewsDate">News Posted:<%#Eval("News_Time")%> &nbsp;&nbsp;&nbsp;<span class="label">NGO1</span>&nbsp;<span class="label">NGO1</span></p>
<p class="NewsDate1"><a href="#">Click here</a> to know more</p>
</div>
</ItemTemplate>
</asp:Repeater>

并根据它从你的数据库中获取数据。在这里,我正在创建演示数据表以在中继器中绑定(bind)静态数据。您可以将其更改为您的数据库数据。

public void bindRepeater()
{
DataTable dtInfo = new DataTable();
dtInfo.Columns.Add("News_Title");
dtInfo.Columns.Add("News_Time");
DataRow dr;
for (int i = 0; i < 5; i++)
{
dr = dtInfo.NewRow();
dr["News_Time"] = DateTime.Now.ToShortDateString();
dr["News_Title"] = "Recongition statement";
dtInfo.Rows.Add(dr);
}
rptNews.DataSource = dtInfo;
rptNews.DataBind();

}


protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
bindRepeater();
}
}

关于c# - 将表中的数据绑定(bind)到前端的转发器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28379551/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com