首页 新闻 搜索 专区 学院

关于多个repeater共用一个itemdatabound

0
悬赏园豆:20 [已关闭问题]
有16个repeater,都是根据一个判断确定是否显示一张图片,用的是一个literal控件这样lit_image.text="&lt;img src=''/&gt;";来显示图片.<br>这些repeater共用protected void Catelist_ItemDataBound(object sender, RepeaterItemEventArgs e)这一个方法来处理。<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bool isChager = false;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string[] arrayItemIndex = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16" };<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (int i = 0; i &lt; arrayItemIndex.Length; i++)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; isChager = bool.Parse(((HiddenField)e.Item.FindControl("hf_Image" + arrayItemIndex[i])).Value);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (isChager)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ((Literal)e.Item.FindControl("ltl_Image" + arrayItemIndex[i])).Text = "&lt;img src='images/other/recomm_green.gif'/&gt; &lt;img src='images/other/recomm_gold.gif'/&gt;";<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ((Literal)e.Item.FindControl("ltl_Image" + arrayItemIndex[i])).Text = "&lt;img src='images/other/recomm_green.gif'/&gt;";<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>这样就出问题了。提示未将对象引用设置到对象的实例。<br><br>我也觉得这样的方法可能有问题,希望高手指教下~<br>
marxTen的主页 marxTen | 初学一级 | 园豆:90
提问于:2008-04-07 11:43
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册