Repeater是不提供分页功能的,DATAGRID却只能以表格形式来表达. 我通过以下代码做到了使Repeater分页, 但在取数据库值进行链接参数时遇到了问题. 请各位指教.
<%@Import Namespace="System.Data"%>
<%@Import Namespace="System.Data.SqlClient"%>
<%@Import NameSpace="System.Configuration"%>
<Script Language="vb" runat="server">
Public strConn As String = ConfigurationSettings.AppSettings("connection")
Public conn As New SqlConnection(strConn)
sub page_load(sender as object,e as Eventargs)
conn.open()
dim adpt as SqlDataAdapter
dim sql="select autoid,fairtitle,fairstarttime from nFair where fairkind='" & request.querystring("fairkind") & "' order by fairstarttime desc" 
dim ds as dataset
adpt=New SqlDataAdapter(sql,conn)
ds=New Dataset()
adpt.fill(ds,"nFair")
dim fairtable as datatable=ds.tables("nFair")
fairtable.columns.add(new DataColumn("html",GetType(string)))
dim i as integer
for i=0 to fairtable.rows.count-1
fairtable.rows(i).item("html")=makehtml(fairtable.rows(i)) 
next
fairs.DataSource=ds.Tables("nFair").Defaultview
fairs.databind()

'regusers.datasource=ds.tables("user_ep").Defaultview
'regusers.databind()
end sub
function makehtml(row as datarow) as string
dim fairtitle=row.item("fairtitle")
dim fairtime=row.item("fairstarttime")
dim html as string
html="<table border='0' width='100%' cellpadding='0' cellspacing='0' bgcolor='#DBDBDB'>"
html &="<tr bgcolor='#F9F9F9'>"
html &="<td width='15'><img src='images/button2.gif' width='14' height='14'></td>"
html &="<td width='250' height='40'>" & fairtitle & "<br>时间:" & fairtime & "</td>"
html &="<td width='100'><div align='center'><a href='fair.aspx?id=" & "'>查看详情</a>" & "</div></td>"
html &="</tr>"
html &="</table>"
return html
end function
</Script><form runat="server">
<td colspan="3">
<asp:Datagrid runat="server" id="fairs" ShowHeader="False" AllowPaging="true" Pagesize="10" AutoGenerateColumns="false" pagerstyle-mode="numericpages" borderwidth="0" align="center" cellpadding="2" cellspacing="0">
<columns>
<asp:boundcolumn datafield="html" headertext="html"/>
</columns>
</asp:Datagrid>
</td>
</form> 
我在查看详情里加一个链接,并读出数据库的AUTOID值,应该怎样做? 请各位指教. 不胜感激.