我实现的是FLASH用CS页里读取数据将直绑定到隐藏域picaddress中然后在JS代码中要用到数据库里的数据就将页面的隐藏域picaddress问题就是出来的数据只有最后一条。但我用CS端用response.write(this.picaddress.Value)结果页面出来一条条数据库里的数据没问题.不知道怎么回事.
public void Page_Load(object sender, EventArgs e)
{ SqlConnection NewsConnection = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["ConnectionString"]); SqlCommand NewsCommand = new SqlCommand("Select Top 5 * From News Where PicNews='True' Order By NewsID Desc ", NewsConnection); try
{
NewsCommand.Connection.Open();
SqlDataReader Dr = NewsCommand.ExecuteReader();
while (Dr.Read())
{ this.picaddress.Value = (Convert.ToString(Dr["NewsPic2"])) + "|";
Response.Write(this.picaddress.Value);
} Dr.Close();
} finally
{
NewsCommand.Connection.Close();
} }
aspx
~/SmallPicture/2007-10-10-06-17-582007-09-19-07-08-21IMG_1219 副本.jpg|http://localhost:1644/GUILIAN/WebAdmin/SmallPicture/2007-10-10-06-48-452007-09-05-06-43-092p524ra20w05cn551dgah345sss.jpg|http://localhost:1644/GUILIAN/WebAdmin/SmallPicture/2007-10-10-06-48-202007-09-09-07-59-04adminlogo.jpg|http://localhost:1644/GUILIAN/WebAdmin/SmallPicture/200406303.jpg|http://localhost:1644/GUILIAN/WebAdmin/SmallPicture/b.jpg|
<script type="text/javascript">
<!--
t=5; //secs per slide// promos + links
prmo = new Array();
link = new Array();var str="http://localhost:1644/GUILIAN/WebAdmin/SmallPicture/b.jpg|";
for( n= 0; n<5; n++)
{
prmo=str.split("|") ;
link="ss"; }//init
promos = "";
links = "";
...
<input type="hidden" name="ctl00$ContentPlaceHolder1$picaddress" id="ctl00_ContentPlaceHolder1_picaddress" value="http://localhost:1644/GUILIAN/WebAdmin/SmallPicture/b.jpg|" />
public void Page_Load(object sender, EventArgs e)
{ SqlConnection NewsConnection = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["ConnectionString"]); SqlCommand NewsCommand = new SqlCommand("Select Top 5 * From News Where PicNews='True' Order By NewsID Desc ", NewsConnection); try
{
NewsCommand.Connection.Open();
SqlDataReader Dr = NewsCommand.ExecuteReader();
while (Dr.Read())
{ this.picaddress.Value = (Convert.ToString(Dr["NewsPic2"])) + "|";
Response.Write(this.picaddress.Value);
} Dr.Close();
} finally
{
NewsCommand.Connection.Close();
} }
aspx
~/SmallPicture/2007-10-10-06-17-582007-09-19-07-08-21IMG_1219 副本.jpg|http://localhost:1644/GUILIAN/WebAdmin/SmallPicture/2007-10-10-06-48-452007-09-05-06-43-092p524ra20w05cn551dgah345sss.jpg|http://localhost:1644/GUILIAN/WebAdmin/SmallPicture/2007-10-10-06-48-202007-09-09-07-59-04adminlogo.jpg|http://localhost:1644/GUILIAN/WebAdmin/SmallPicture/200406303.jpg|http://localhost:1644/GUILIAN/WebAdmin/SmallPicture/b.jpg|
<script type="text/javascript">
<!--
t=5; //secs per slide// promos + links
prmo = new Array();
link = new Array();var str="http://localhost:1644/GUILIAN/WebAdmin/SmallPicture/b.jpg|";
for( n= 0; n<5; n++)
{
prmo=str.split("|") ;
link="ss"; }//init
promos = "";
links = "";
...
<input type="hidden" name="ctl00$ContentPlaceHolder1$picaddress" id="ctl00_ContentPlaceHolder1_picaddress" value="http://localhost:1644/GUILIAN/WebAdmin/SmallPicture/b.jpg|" />
改
while (Dr.Read())
{ this.picaddress.Value = (Convert.ToString(Dr["NewsPic2"])) + " ¦";
Response.Write(this.picaddress.Value);
}
为-->
while (Dr.Read())
{ this.picaddress.Value += (Convert.ToString(Dr["NewsPic2"])) + " ¦";
Response.Write(this.picaddress.Value);
}