关于数据绑定在Web页面呈现效果的一点小技巧
时间:2007-01-21 14:06:08
来源: 作者: 点击:次 出处:技术无忧
关键字:关于
今天在开发当中遇到:一个栏目要求以上图的方式显示,我用了2个DataGrid绑定一个1个栏目,“ 医药内幕”这个栏目的数据库编号是:category1=1,category2=2。
左边我用DataGrid1来帮定:呈现的数据是“医药内幕”栏目里TOP前 4 位的记录
string str1 = "select top 4 title from NewsInfo where category1=1 and category2=2 order by id desc";
DataGrid1.DataSource = sqlBase.ExecuteDataView(str1);
DataGrid1.DataBind();
右边边我用DataGrid2来帮定:呈现的数据是“医药内幕”栏目里TOP 前8 位中后 4 位的记录
string str1 = "select top 4 title from NewsInfo where id
not in ( select top 4 id from NewsInfo where category1=1 and category2=2
order by id desc ) and category1=1 and category2=2order by id desc";
DataGrid1.DataSource = sqlBase.ExecuteDataView(str1);
DataGrid1.DataBind();
这样邦定,就可以让一个栏目的数据在页面上分2个地方甚至多个地方显示,而且可以不重复的显示最新的记录,关键用到了SQl当中的 not in()。这是我所体会的,希望大家指正。
你有email邮箱吗?经常收到垃圾邮件而烦吗?立即使用邮箱LOGO在线制作酷Email logo图片
下一篇:为按钮添加 确认 对话框










文章评论
共有 0 位网友发表了评论 此处只显示部分留言 点击查看完整评论页面