数据库:
表NewsType--新闻类型
字段 id newsType
1 娱乐新闻
2 体育新闻
3 国内新闻
4 国外新闻
表News--新闻内容
字段 newsid newsTitle newsContent id(外键)请问
后台管理怎么怎么用DATALIST实现这样的功能
标题 内容 新闻类型
让新闻类型的值显示为新闻应该所属的类型如果在ASPX页面用直接用
<asp:dropdownlist id="" runat="" SelectedValue='<%#Eval("id")%>'>
<asp:LIstItem text="" value=""></asp:LIstitem></asp:dropdownlist>这个样式的我会但是怎么样不在ASPX页面中用<asp:listitem></asp:listitem>这样手动添加项
而直接绑定到数据库,然后显示新闻的类型呢
表NewsType--新闻类型
字段 id newsType
1 娱乐新闻
2 体育新闻
3 国内新闻
4 国外新闻
表News--新闻内容
字段 newsid newsTitle newsContent id(外键)请问
后台管理怎么怎么用DATALIST实现这样的功能
标题 内容 新闻类型
让新闻类型的值显示为新闻应该所属的类型如果在ASPX页面用直接用
<asp:dropdownlist id="" runat="" SelectedValue='<%#Eval("id")%>'>
<asp:LIstItem text="" value=""></asp:LIstitem></asp:dropdownlist>这个样式的我会但是怎么样不在ASPX页面中用<asp:listitem></asp:listitem>这样手动添加项
而直接绑定到数据库,然后显示新闻的类型呢
解决方案 »
- ajax,2个与服务器有关的问题,全部的90拿去,谢谢
- 以前同事说问我个简单的问题,结果把我难住了,求大侠解答
- .NET弹出提示框问题
- [求助]win7下vs2008与sql2005连接不上
- 怎么实现点击按钮出现一些数据行,再点击再出现一些行,就像发邮件添加多个附件那样
- |M| 用什么方法来实现网站记录客户端电脑的唯一性 第二贴
- DropDownList邦定问题
- 哪位前辈能否说说连接SQL Server方法?
- datagrid合計問題
- 动态绑定dropdownlist后,如何再加一行呢?
- 在Paga_Load里自己写SQL语句来得到数据,绑定到GridView1上,如何实现GV1的分页功能?
- smtp服务器 C#中发送邮件
外面层显示分类信息,然后里面的那层根据分类ID查找对应的详细信息就行了
<asp:dataList ...........>
<ItemTemplate>
<table>
<tr>
<td>Eval("newsType") </td>
</tr>
<tr>
<td> <asp:dataList ...........> //这里嵌套一个DATALIST显示详细信息,条件就是分类ID
<ItemTemplate>
<table>
<tr>
<td>绑定详细信息Eval("newsTitle") </td>
</tr>
</table>
</ItemTemplate>
</asp:dataList>
</td>
</tr>
</table> </ItemTemplate>
</asp:dataList>
<ItemTemplate>
<table width="100%" height="25" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="2%"> </td>
<td width="23%"><img src="images/dian.jpg" width="17" height="14">
<%#DataBinder.Eval(Container.DataItem, "newsTitle")%></td>
<td width="55%">
<%#DataBinder.Eval(Container.DataItem, "newsContent")%></td>
<td width="20%"><%# GetNewsTypeById(DataBinder.Eval(Container.DataItem,"id")) %></td>
</tr>
</table>
</ItemTemplate></asp:DataList>说明:GetNewsTypeById根据id得到新闻类型
这样应该可以的,不知道窝是否理解错误你的意思?
DropDownList1.DataTextFiled="newsType";
DropDownList1.DataValueField="id";
DropDownList1.DataBind();
ID title Content style issueDate
xx xxx xxx xxx xxxx
1、新闻,各个版块分开显示,比如:时政版块(第一个DataList) .
SELECT TOP 5 * FROM tbNews WHERE (Style = '时政要闻'and issueDate='"+DateTime.Today.ToString()+"')", "tbNews");
经济动向 版块 (第2个DataList)
SELECT TOP 5 * FROM tbNews WHERE (Style = '经济动向'and issueDate='" + DateTime.Today.ToString() + "')", "tbNews");
2、最新 新闻混合显示,不要加Where 就行
SELECT TOP 5 * FROM tbNews
绑定的时候 放4列,title Content style issueDate 就行。