青草伊人网,精品一区二区三区四区电影,日本高清中文,欧美日韩国产成人高清视频,美女艺术照片,潘春春的大尺度裸乳,椎名真白高清图

首頁>茶油新聞>包括新聞分類和標(biāo)題和添加時(shí)間,單擊標(biāo)題跳轉(zhuǎn)到新聞內(nèi)容顯示頁?

包括新聞分類和標(biāo)題和添加時(shí)間,單擊標(biāo)題跳轉(zhuǎn)到新聞內(nèi)容顯示頁?

來源:www.cisanotes.com   時(shí)間:2021-06-02 05:08   點(diǎn)擊:5290   編輯:niming   手機(jī)版

??下面是用datagrid的例子(我用的是用戶自定義控件)※hotNews。ascx 部分代碼1。寫一個(gè)連接數(shù)據(jù)庫的類 通過它建立連接SqlConnection conn=DB。createconn();2。創(chuàng)建命令SqlCommand cmd=new SqlCommand("select top 10 * from newsMaster ",conn);conn。
??Open();SqlDataReader sdr=cmd。ExecuteReader();3。綁定數(shù)據(jù)源this。DataGrid1。DataSource=sdr;4。綁定datagridthis。DataGrid1。DataBind();※頁面部分: 只需在自定義控件中加入datagrid設(shè)置一下< id="DataGrid1" runat="server" Width="283px" GridLines="Horizontal" AutoGenerateColumns="False"ShowHeader="False" Height="100%"><ItemStyle Height="10px"></ItemStyle><Columns>< color="#ffffff">※</FONT></ItemTemplate></ :HyperLinkColumn DataNavigateUrlField="newsID" DataNavigateUrlFormatString="ShowNews。
??aspx?newsID={0}"DataTextField="newsTitle"></ /Columns></ /P>※ShowNews。aspx通過Request。QueryString["newsID"]得到傳來的newsID然后從數(shù)據(jù)庫中讀取該條新聞 顯示在該頁面就可以了 §后臺(tái)代碼§string strNewsID=Request。
??QueryString["newsID"];SqlConnection con=DB。createconn();con。Open();SqlCommand cmd=new SqlCommand("select * from newsMaster where newsID='"+strNewsID+"'",con);SqlDataAdapter adpater=new SqlDataAdapter();adpater。
??SelectCommand=cmd;DataSet ds=new DataSet();adpater。Fill(ds,"newsMaster");DataTable dt=ds。Tables["newsMaster"];this。DataList1。
??DataSource=dt;this。DataList1。DataBind();cmd。Dispose();con。Close();§頁面部分§我用的datagrid接受數(shù)據(jù) 因?yàn)樾侣剝?nèi)容不定的: < id="DataList1" runat="server"><ItemTemplate><TABLE id="Table2" cellSpacing="1" cellPadding="1" width="300" border="1"><TR><TD>標(biāo)題:<%# DataBinder。
??Eval(Container。DataItem,"newsTitle")%></TD></TR><TR><TD><%# DataBinder。Eval(Container。DataItem,"newsContent")%></TD></TR><TR><TD>發(fā)表時(shí)間:<%# DataBinder。
??Eval(Container。DataItem,"updateTime")%></TD></TR></TABLE></ItemTemplate></ 代碼絕對(duì)有效的。

寫得不錯(cuò)

??寫語句:select top 10 新聞分類,標(biāo)題,添加時(shí)間 from 新聞where 。。。。。。。放入 void oncesql(string strsql,string tname,DataSet dst) { SqlConnection oconnection=new SqlConnection(connstr); oconnection。
??Open(); SqlDataAdapter sqldataadapter1 = new SqlDataAdapter(); SqlCommand ocommand = new SqlCommand(); sqldataadapter1。
??SelectCommand = ocommand; sqldataadapter1。SelectCommand。Connection = oconnection; sqldataadapter1。SelectCommand。CommandType = CommandType。
??Text; sqldataadapter1。SelectCommand。Connection = oconnection; sqldataadapter1。SelectCommand。CommandText = strsql; sqldataadapter1。
??Fill(dst, tname); oconnection。Dispose(); sqldataadapter1。Dispose(); ocommand。Dispose(); }綁寫數(shù)據(jù)源 this。dgrd_fzr。DataSource=dst。
??Tables["????"]; this。dgrd_fzr。DataBind();頁面部分自己寫了,。

感覺不錯(cuò),贊哦! (0)
下次努力,加油! (0)
網(wǎng)友評(píng)論僅供其表達(dá)個(gè)人看法,并不表明本站立場(chǎng)。
評(píng)論
    共 0 條評(píng)論
本站所發(fā)布的全部?jī)?nèi)容源于互聯(lián)網(wǎng)搬運(yùn),僅限于小范圍內(nèi)傳播學(xué)習(xí)和文獻(xiàn)參考,請(qǐng)?jiān)谙螺d后24小時(shí)內(nèi)刪除!
如果有侵權(quán)之處請(qǐng)第—時(shí)間聯(lián)系我們刪除。敬請(qǐng)諒解!qq:2850716282@qq.com
山茶油 滇ICP備2021006107號(hào)-532
關(guān)于本站 聯(lián)系我們 特別鳴謝