【问题标题】:Datalist itemcommand design?数据列表项命令设计?
【发布时间】:2019-05-25 04:00:35
【问题描述】:

在我的应用程序中,我使用 datalist 来显示图像,我放置了 repeatcolumn=4 和 reapeatdirection=horizo​​ntal 的属性。如果只有 1 个或 2 个或 3 个图像,并且图像之间的间隙 r 太长,则当有 r 个或 4 个以上的图像时显示良好。如果我只有一张图像,则图像显示在数据列表中间的数据列表中。我怎么解决这个问题。我想你们理解我的问题这是我的 datalist 源代码... datalist width="100%"

<asp:DataList ID ="dtlstallfrind" RepeatColumns ="4" RepeatDirection="horizontal"widht=100> 

    <ItemTemplate >

          <table width="100%" >

            <tr>
               <td  >

                  <asp:ImageButton ID="imgeFrien" runat ="Server" Width="110px" Height ="100px" CommandName ="Image" CommandArgument ='<%# Eval("userid") %>' ImageUrl ='<%# "~/Userimages/"+ Eval("myimage") %>' />
               </td>
            </tr>
            <tr>
               <td >
                  <asp:Label ID="lblFrieNam" runat ="Server" Font-Names ="verdana"  Text ='<%# Eval("username") %>'></asp:Label> 
               </td>
            </tr>
          </table>
       </ItemTemplate>
   </asp:DataList>

【问题讨论】:

    标签: asp.net


    【解决方案1】:

    当你尝试这个时会发生什么?

    <ItemTemplate >   
    
        <asp:ImageButton ID="imgeFrien" runat ="Server" Width="110px" Height ="100px" 
            CommandName ="Image" CommandArgument ='<%# Eval("userid") %>' ImageUrl ='<%# 
            "~/Userimages/"+ Eval("myimage") %>' />
    
        <asp:Label ID="lblFrieNam" runat ="Server" Font-Names ="verdana"  Text ='<%# 
             Eval("username") %>'></asp:Label> 
    
    </ItemTemplate>
    

    【讨论】:

    • no Mr.steve 显示的是相同的,用户名出现在图像旁边。
    • 如果您为 Datalist 设置了宽度,请取消设置。 Datalist 呈现一个表。如果表格有固定的,单元格将扩大到宽度。你能发布整个数据列表代码吗?
    • 如果图片向右浮动,文字会在图片下方。
    • 它工作正常,我删除了 datlist 的宽度,它工作正常谢谢史蒂夫先生
    【解决方案2】:

    尝试使用RepeatLayout="Flow" ItemStyle="float:left;" 看看会发生什么...让我知道它的作用?

    【讨论】:

    • 好的,我会尝试通知你。现在我要去吃午饭了,我会在 5000 万内回复 好的,谢谢您的回复
    • 先生。 Pandiya Chendur 当我在下面输入 ItemStyle 时,它​​显示绿色标记,表示它是无效属性并且图像垂直显示
    • 在itemstyle标签中我没有找到任何浮动:当我放置它时在页面中给出错误
    • @sasidar 使用 css .urclass{float:left;} in css 并在 &lt;itemstyle&gt; 中包含 CssClass 名称为 &lt;ItemStyle CssClass="urclass"&gt;
    • 没有 Mr.Pandiya Chendur 图像或显示有间隙这是我的代码
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-09-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多