<
atlas:ScriptManager
ID
="ScriptManager1"
runat
="server"
>
</ atlas:ScriptManager >
< table id ="NewsList" width ="98%" border ="0" align ="center" cellpadding ="0" cellspacing ="0" >
< tbody id ="NewsItemTemplateParent" >
< tr id ="NewsItemTemplate" >
< td width ="72%" height ="22" >< a href ="#" class ="link2" > ∴ < span id ="Newstitle" class ="link2" ></ span ></ a ></ td >
< td width ="28%" class ="zt3" >< span id ="NewsTime" class ="link2" ></ span ></ td >
</ tr >
</ tbody >
</ table >
< script type ="text/xml-script" >
<page xmlns:script="http://schemas.microsoft.com/xml-script/2005">
<components>
<dataSource id="NewslistDataSource" autoLoad="true" serviceURL="NewsService.asmx" />
<listView id="News" itemTemplateParentElementId="NewsItemTemplateParent">
<bindings>
<binding dataContext="NewslistDataSource" dataPath="data" property="data" />
</bindings>
<layoutTemplate>
<template layoutElement="NewsList" />
</layoutTemplate>
<itemTemplate>
<template layoutElement="NewsItemTemplate">
<label id="Newstitle">
<bindings>
<binding dataPath="Title" property="text" />
</bindings>
</label>
<label id="NewsTime">
<bindings>
<binding dataPath="HDate" property="text" />
</bindings>
</label>
</template>
</itemTemplate>
</listView>
</components>
</page>
</ script >
</ atlas:ScriptManager >
< table id ="NewsList" width ="98%" border ="0" align ="center" cellpadding ="0" cellspacing ="0" >
< tbody id ="NewsItemTemplateParent" >
< tr id ="NewsItemTemplate" >
< td width ="72%" height ="22" >< a href ="#" class ="link2" > ∴ < span id ="Newstitle" class ="link2" ></ span ></ a ></ td >
< td width ="28%" class ="zt3" >< span id ="NewsTime" class ="link2" ></ span ></ td >
</ tr >
</ tbody >
</ table >
< script type ="text/xml-script" >
<page xmlns:script="http://schemas.microsoft.com/xml-script/2005">
<components>
<dataSource id="NewslistDataSource" autoLoad="true" serviceURL="NewsService.asmx" />
<listView id="News" itemTemplateParentElementId="NewsItemTemplateParent">
<bindings>
<binding dataContext="NewslistDataSource" dataPath="data" property="data" />
</bindings>
<layoutTemplate>
<template layoutElement="NewsList" />
</layoutTemplate>
<itemTemplate>
<template layoutElement="NewsItemTemplate">
<label id="Newstitle">
<bindings>
<binding dataPath="Title" property="text" />
</bindings>
</label>
<label id="NewsTime">
<bindings>
<binding dataPath="HDate" property="text" />
</bindings>
</label>
</template>
</itemTemplate>
</listView>
</components>
</page>
</ script >
调用webservice用ListView显示新闻标题和日期.
[WebMethod]
public DataTable GetData()
{
string sql ="select top 5 * from news";
DataSet ds = DataAsseccSQL.ExecuteDataset(sql);
DataTable dt = ds.Tables[0];
return dt;
}
具体参考了 http://www.cnblogs.com/dflying/archive/2006/04/08/370331.html
<binding dataPath="Title" property="text" /> 这个一定要和数据库的名称一模一样,否则显示为undefined
我搞了个网络延时的,特意让WebService休眠.
System.Threading.Thread.Sleep(5000);
<atlas:UpdateProgress ID="UpdateProgress1" runat="server">
<ProgressTemplate >Loading.....</ProgressTemplate>
</atlas:UpdateProgress>
但效果没出来!