使用 adrotator 控件显示数据
我正在使用 asp.net 和 C#。
我有一个通过数据库绑定的 adrotator。我在数据库表
- AdId
- AdTitle
- AlternateText
- ImageUrl
- NavigateUrl
- AdDescription
中有以下列,它正确绑定并显示数据,现在我想要在 adrotator 右侧有一个标签,显示 AdDescription,但它仅显示第一条记录。 我将尝试用代码
private void GetPopUpData()
{
string conn = "Data Source=KKR;Initial Catalog=XYZ;Integrated Security=True";
SqlConnection Scon = new SqlConnection(conn);
Scon.Open();
SqlDataAdapter da = new SqlDataAdapter("Select * FROM tblAd", Scon);
DataSet ds = new DataSet();
da.Fill(ds);
AdRotator1.DataSource = ds.Tables[0];
AdRotator1.DataBind();
lblDesc.Text = ds.Tables[0].Rows[0]["AdDescription"].ToString();
}
protected void timer1_Tick(object sender, EventArgs e)
{
GetPopUpData();
}
请帮助我在广告旋转器右侧显示文本数据来向您解释,因为它仅显示第一条记录的数据。可能是因为我使用了Rows[0]
。
提前致谢
I am using asp.net with C#.
I have a adrotator which I am binding through the database. I have following column in database table
- AdId
- AdTitle
- AlternateText
- ImageUrl
- NavigateUrl
- AdDescription
It is binding correctly and showing the data, now I want a label on the right of the adrotator which show the AdDescription, but it is showing the first record only.
I'll try to explain you with the code
private void GetPopUpData()
{
string conn = "Data Source=KKR;Initial Catalog=XYZ;Integrated Security=True";
SqlConnection Scon = new SqlConnection(conn);
Scon.Open();
SqlDataAdapter da = new SqlDataAdapter("Select * FROM tblAd", Scon);
DataSet ds = new DataSet();
da.Fill(ds);
AdRotator1.DataSource = ds.Tables[0];
AdRotator1.DataBind();
lblDesc.Text = ds.Tables[0].Rows[0]["AdDescription"].ToString();
}
protected void timer1_Tick(object sender, EventArgs e)
{
GetPopUpData();
}
Please help me in displaying the text data on the right side of the adrotator, as it is only showing the data of the first record. might be because i have used Rows[0]
.
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
现在不在我的 IDE 后面,但是您可以使用 ActiveRow 或类似的属性吗?
另外,如果 addrotator 后面的表中的光标正在更改,您还可以挂钩数据事件而不是计时器或弹出窗口,这可能会更干净。
Not behind my IDE right now, but is there an ActiveRow or similar property you could be using?
Also, if the cursor in the table behind the addrotator is changing, you could also hook to a data event instead of a timer or popup, this might be cleaner.