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, "Image Path") %>'值存储在其他变量中,或者我如何打印 ImageUrl 路径?

4

1 回答 1

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;
         }
      }

要获取更多详细信息,请阅读此..

于 2012-09-10T05:58:50.520 回答