asp.net c# 创建小说网站时的问题

Python012

asp.net c# 创建小说网站时的问题,第1张

都好基础的问题。

1.点button的时候改变查询语句。再绑定到GridView。

比如:

GridView.DataSource = dt(dt就是数据库中查找的数据,可以是datatable,集合实体类,等等)

GridView.DataBind()

假设dt是用select * from 表名 为查询语句的数据源。(当然用*只是讲解。如果你有能力的话请最好不要用* 最好写个分页查询语句作为数据源)

当点按钮的时候,在按钮的点击事件中只要改变GridView绑定的数据源。

GridView.DataSource = newdt

GridView.DataBind()

newdt 假设用select * from where type='xxx' 作为数据源

2.第二个问题。前台后台都可以。但做这种的。用前台就能搞定了。

第一步先把要作为连接的那一列转化为模板。(这步你该知道吧。不知道了再说)

第二步因为你做这个不需要太麻烦。所以只要用a标签就够了。我就随便用我目前的项目说说 了。

转为模板后会变成下面

<asp:TemplateField HeaderText="原供价(元)/包">

<ItemTemplate>

<asp:Label ID="Label2" runat="server" Text='<%# Bind("LotPrice") %>'></asp:Label>

</ItemTemplate>

<EditItemTemplate>

<asp:TextBox ID="txtExwPrice" runat="server" Text='<%# Bind("LotPrice") %>' Width="60px" onblur="CheckNum(this)"></asp:TextBox>

</EditItemTemplate>

<ItemStyle Width="15%" />

</asp:TemplateField>

没用到GridView编辑功能

所以直接删掉

<EditItemTemplate>

<asp:TextBox ID="txtExwPrice" runat="server" Text='<%# Bind("LotPrice") %>' Width="60px" onblur="CheckNum(this)"></asp:TextBox>

</EditItemTemplate>

然后修改<ItemTemplate>中的内容。

改为

<ItemTemplate>

<a href='你要跳转的页面.aspx?id=<%# #Eval("ID") %>' >

<asp:Label ID="lblPartModel" runat="server" Text='<%# Eval("列名") %>'></asp:Label>

</a>

</ItemTemplate>

3.就关系你页面问题了。不知道页面长怎样我不好说。

文件都是现成的吗?

如果文件都是现成的话,那么你只需要建一张表,示例表结构

id小说编号

name小说名称

author小说作者

totalCount总字数

url小说文件路径

小说阅读页,根据url小说路径,读取对应文件中的内容,然后显示在网页上