2012-09-10 34 views
1
<asp:DataList ID="dlAssignftp" Visible="false" runat="server" RepeatColumns="5" RepeatDirection="Vertical" 
      HorizontalAlign="left" CellPadding="1" CellSpacing="1" Width="100%"> 
      <ItemTemplate> 
       <ul class="gallery clearfix slideshow"> 
        <li> 
<a href='<%# DataBinder.Eval (Container.DataItem, "Image Path") %>' rel="prettyPhoto[pp_gal]">     
         <asp:Image ImageUrl='<%# DataBinder.Eval (Container.DataItem, "Image Path") %>' ID="imgftp" 
          runat="server" Height="100px" Width="100px" Visible="true" /> 
         </a>       
        </li>   
        <asp:RadioButton ID="rbtn_ftpimg" runat="server" Text="Select" TextAlign="Right" AutoPostBack="true" GroupName='<%# DataBinder.Eval (Container.DataItem, "Image Path") %>' OnCheckedChanged="rbtn_ftpimg_Changed" />    
       </ul>      
      </ItemTemplate> 

     </asp:DataList> 

存儲數據綁定值在上述ASCX代碼,如何能夠存儲「<%#的DataBinder.Eval(的Container.DataItem, 」圖像路徑「)% >'某些其他變量的值,或簡單地如何打印ImageUrl路徑?如何在其他變量在asp.net

+0

我不知道如果我理解你的問題。你有沒有嘗試從代碼隱藏'imgftp.ImageUrl'? –

+0

實際上它是一個實時網站,它已經顯示了使用FTP加載的圖像,而ascx顯示了數據列表中的img,我的wrk是爲每個圖像放置單選按鈕(因爲imgs和img loc可能不同),以及在rB中選擇適當的img shud的細節顯示在警告框中,你有什麼想法嗎? – user1654537

回答

0

使用hidden值控制asp.net並將值存儲在其上。

<asp:hiddenfield id="ValueHiddenField" value='<%# DataBinder.Eval (Container.DataItem, "Image Path") %>' runat="server"/> 

使用DataList_ItemDataBound事件讓每一個隱藏字段

Protected void Item_Bound(Object sender, DataListItemEventArgs e) 
     { 
     if (e.Item.ItemType == ListItemType.Item || 
      e.Item.ItemType == ListItemType.AlternatingItem) 
     { 

      // Retrieve the ValueHiddenField control in the current DataListItem. 
      HiddenField imgPath = (HiddenField)e.Item.FindControl("ValueHiddenField"); 
      string path = imgPath.Value; 
     } 
     } 

的價值如需更多信息閱讀this..

+0

它存儲達達綁定值嗎? – user1654537

+0

@ user1654537看到我更新的答案 – Talha

相關問題