[英]how to store databind value in other variable in asp.net
<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
的hidden
值控件並在其中存儲值。
<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;
}
}
要獲取更多詳細信息,請閱讀此。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.