ASP.net新闻列表怎么做,就是左边是新闻标题,右边是新闻发布日期,好像要读取数据库什么的
一般做这个的话,从数据库读出数据,去了解一下ado.net
例如数据表
id title content lastDateTime三个字段。
那么读取数据
//你说使用reader的方法读取数据库中的数据,使用ado.net中的几个对象 。
string sql = "select * from table"
SqlCommand cmd = new SqlCommand(sql, 连接对象。 );
connection.Open();
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
reader["id"]
reader["title"]
reader["content"]
reader["lastDateTime"]
}
connection.Close();
//读出数据后展示title和时间,
然后和2楼说的一样。根据url传参,获取id查询news的id查询出内容,
进行展示。
<a href="news.aspx?id= " >