1
1楼 Mylida 2007-08-23 08:49:27 绑定数据函数 (1) private void BindFileDown() { for(...) { ds.Tables[0].Rows[i][ "PictureName "] = " <a title= ' " + FileSize + " ' href= '# ' onclick=\ "javascript:popWindows( '../../DLPicture.aspx? " + Constant.Query_DownloadRefNum + "= " + ds.Tables[0].Rows[i][ "DocID "].ToString() + " ')\ "> <img width=80 height=60 border=0 src= '../../DLPicture.aspx? " + Constant.Query_DownloadRefNum + "= " + ds.Tables[0].Rows[i][ "DocID "].ToString() + " ' /> </a> "; ---> 这行读取图片到img 在链接图片,点击可以打开图片 } A.DataSource = ds; A.DataBind(); } 若是这样图片能正常读出. (2) private void A_ItemDataBound(...) { e.Item.Cells[9].Text = " <div id=Confid " + key + " > " + e.Item.Cells[9].Text + " </div> " + tempDdl; .... HtmlInputFile Picture=new HtmlInputFile();//Picture Picture.Style.Add( "display ", "none "); Picture.Style.Add( "width ", "150 "); Picture.ID= "Picture " + key; e.Item.Cells[12].Controls.Add(Picture); --> 想实现当点更改时,可以更改图片,但增加这几句后,图片就不能读取,DataGrid的PictureName列为空,为何会是这样? 前面不是梆定了吗? } (3) private void A_ItemDataBound(...) { ... 也可在这重新读图片 HtmlImage im=new HtmlImage(); im.Style.Add( "width ", "80 "); im.Style.Add( "height ", "60 "); im.Style.Add( "border ", "0 "); im.Src= "../../DLPicture.aspx? " + Constant.Query_DownloadRefNum + "= " + ds.Tables[0].Rows[e.Item.ItemIndex][ "DocID "].ToString(); e.Item.Cells[12].Controls.Add(im);//add 但我怎样对im图片控件 做链接?? " <a title= ' " + FileSize + " ' href= '# ' onclick=\ "javascript:popWindows( '../../DLPicture.aspx? " + Constant.Query_DownloadRefNum + "= " + ds.Tables[0].Rows[i][ "DocID "].ToString() + " ')\ "> 这句怎样加上去? } 麻烦各位达人,出出策,谢谢~~ 2楼 Mylida 2007-08-23 09:07:29 没人吗... 3楼 morixing 2007-08-23 09:36:55 把添加图片那里修改,Lable Lb = new Lable(); Lb.Text = " <a title= ' " + FileSize + " ' href= '# ' onclick=\ "javascript:popWindows( '../../DLPicture.aspx? " + Constant.Query_DownloadRefNum + "= " + ds.Tables[0].Rows[i][ "DocID "].ToString() + " ')\ "> <img src=\ "../../DLPicture.aspx? " + Constant.Query_DownloadRefNum + "= " + ds.Tables[0].Rows[e.Item.ItemIndex][ "DocID "].ToString();+ " </a> "; e.Item.Cells[12].Controls.Add(Lb); 或者 e.Item.Cells[12].Text = " <a title= ' " + FileSize + " ' href= '# ' onclick=\ "javascript:popWindows( '../../DLPicture.aspx? " + Constant.Query_DownloadRefNum + "= " + ds.Tables[0].Rows[i][ "DocID "].ToString() + " ')\ "> <img src=\ "../../DLPicture.aspx? " + Constant.Query_DownloadRefNum + "= " + ds.Tables[0].Rows[e.Item.ItemIndex][ "DocID "].ToString();+ " </a> "; 即直接把Html代码写入到列上就OK了,//一上字符串是把你的拿来临时拼凑的,本人不保证不报错,不过方法应该已经表达清楚了吧-。- 4楼 Mylida 2007-08-23 11:15:54 嗯,感谢 morixing(),方法应该可行了,谢谢~~
我在图片控件上加了Onclick事件,也算是可以链接了 在ItemDataBound(...)事件中 为何在某列加了控件后 前面数据源中某列的数据就读不出来呢?好像是被隐藏到了? private void BindFileDown() { for(...) { ds.Tables[0].Rows[i][ "PictureName "] = " <a title= ' " + FileSize + " ' href= '# ' onclick=\ "javascript:popWindows( '../../DLPicture.aspx? " + Constant.Query_DownloadRefNum + "= " + ds.Tables[0].Rows[i][ "DocID "].ToString() + " ')\ "> <img width=80 height=60 border=0 src= '../../DLPicture.aspx? " + Constant.Query_DownloadRefNum + "= " + ds.Tables[0].Rows[i][ "DocID "].ToString() + " ' /> </a> "; // ---> 这里 } A.DataSource = ds; A.DataBind(); }
搜索墙@2009 www.pkwall.com all rights reserved QQ:276471788 [京ICP备09111534号]
声明:本站部分数据来源于网络,仅供参考,如有版权问题,请联系我们,我们将及时删除!转载本站请注明来源
| |||||