|
查看: 1003|回复: 11
|
asp 转换 .net
[复制链接]
|
|
|
这是我们常用的asp code,dispay record
<%while not rs.eof%>
<tr>
<td><%=rs("name")%></td>
<td><%=rs("ic")%></td>
</tr>
<%rs.movenext
wend%>
但是如果想转换去.net,除了用response.write以外,<tr><td><table>这些html code 该怎么写
<script language="vb" runat="server">
while rs.read()
'html 的code 在asp.net 里该怎么写
end while
</script> |
|
|
|
|
|
|
|
|
|
|
发表于 27-6-2008 10:08 PM
|
显示全部楼层
在.net, coding是和html tag分开的
然后如果要retrieve value from database通常我们是用gridview or datagrid
把datagrid/gridview drag to webform ,然后name the datagrid as "dg" or whatever name you like
code behind
dim dt as new datatable
dim sql = select * from customer
dim conn as new sqlconnection(connectionstring)
dim cmd as new sqlcommand(sql, conn)
dim da as new sqldataadapter(cmd)
da.fill(dt)
if dt.rows.count > 0 then
dg.datasource = dt
dg.databind()
end if
你的case是不需要loop liao..,因为in dot net, bind data过后, 就会拿完所有data了 |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 2-7-2008 09:05 AM
|
显示全部楼层
原帖由 stephanie83 于 27-6-2008 10:08 PM 发表 
在.net, coding是和html tag分开的
然后如果要retrieve value from database通常我们是用gridview or datagrid
把datagrid/gridview drag to webform ,然后name the datagrid as "dg" or whatever name you like
...
这样的话, .net environment 不允许 customization 咯, 因为如果用datagrid , 很多都不能customize |
|
|
|
|
|
|
|
|
|
|
发表于 2-7-2008 09:12 AM
|
显示全部楼层
|
可以CUSTOMISE ,你要CUSTOMISE什么? |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 2-7-2008 10:19 AM
|
显示全部楼层
原帖由 bee002 于 2-7-2008 09:12 AM 发表 
可以CUSTOMISE ,你要CUSTOMISE什么?
recordlist 的 look & feel
还有如:
如果value 是 negative 的话, cell bgcolor=red, positive 就blue ,之类的 customization
[ 本帖最后由 牵牛 于 2-7-2008 10:21 AM 编辑 ] |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 2-7-2008 05:17 PM
|
显示全部楼层
|
还有在.net , 从db retrieve record 然后 add 进 item list的 algorithm 是怎样的 |
|
|
|
|
|
|
|
|
|
|
发表于 2-7-2008 06:43 PM
|
显示全部楼层
你可以customize datagrid 的
比如说
go to properties set the datagrid style
至于当value是negative的话
你必须在code behind写 |
|
|
|
|
|
|
|
|
|
|
发表于 2-7-2008 06:44 PM
|
显示全部楼层
原帖由 牵牛 于 2-7-2008 05:17 PM 发表 
还有在.net , 从db retrieve record 然后 add 进 item list的 algorithm 是怎样的
不是很明白...
add 进 item list ??那里的item list? |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 3-7-2008 11:09 AM
|
显示全部楼层
原帖由 stephanie83 于 2-7-2008 06:44 PM 发表 
不是很明白...
add 进 item list ??那里的item list?
itemlist 是这个东东
在 asp 里 如果我retrieve from db,然后add in....eg
<select >
<%while not rs.eof>
<option value=<%=rs(0)%>><%=rs(0)%></option>
<%rs.movenext
wend%>
</select>
.net 该怎么写? |
|
|
|
|
|
|
|
|
|
|
发表于 3-7-2008 06:41 PM
|
显示全部楼层
可以去google找啊
bind to dropdown list
很多example |
|
|
|
|
|
|
|
|
|
|
发表于 3-7-2008 11:41 PM
|
显示全部楼层
ASP 与 ASP.NET 根本是天与地的差别 ..
想当年,我在 www.asp.net 自学ASP.NET..
如果有心学的话, 去那儿练功吧..
而不是在这里问简单的问题.. 要问就问些有水准的问题吧.. |
|
|
|
|
|
|
|
|
|
|
发表于 7-7-2008 03:15 PM
|
显示全部楼层
要BIND去DROPDOWNLIST,你DB-〉DATASET
然后
DROPDOWNLIST.DataTextField = "textfieldName"
DROPDOWNLIST.DataValueField= "valuefieldName"
DROPDOWNLIST.datasource = dataset.table(0)
DROPDOWNLIST.databind
gao TIM |
|
|
|
|
|
|
|
|
| |
本周最热论坛帖子
|