Hi Gav,
Thank you for posting in the community! My name is Jeffrey, and I will be
assisting you on this issue.
Based on my understanding, you use DataList control to display a serial of
linkbuttons, and you set its width property to 100% to make its fulfill the
browser window.
But, when you resize your browser window, the pictures always show in one
horizontal line, not wrap, so a horizontal scroll bar will display out.
======================================================
Actually, DataList control will render as <table> <tr> <td>, so in your
source code, you will see that all the imagebutton will be inclued in <td>
tags and in one <tr> tag.(You can determine this through view the page's
html source code)
So the images will not wrap.
I think the simplest way to get what you want(Wrap the images when browser
window resize) is using Repeater server control, which is similar as the
DataList control.
The repeater control give you more customize control of the rendering. It
will not render the <table> tag for you. So it will wrap the images follows
the browser window's size change.
You can try the following Solution to see if it helps resolve your issue:
<asp:Repeater id="Repeater1" runat="server">
<ItemTemplate>
<asp:ImageButton ImageUrl="lgout.jpg" id="ImageButton1" runat="server"
Width="136px" borderwidth="6"
bordercolor="#ffffcc"></asp:ImageButton>
</ItemTemplate>
</asp:Repeater>
protected System.Web.UI.WebControls.Repeater Repeater1;
private void Page_Load(object sender, System.EventArgs e)
{
DataTable dt= new DataTable();
DataRow dr;
dt.Columns.Add("test");
dr = dt.NewRow();
dr[0] = "1";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr[0] = "2";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr[0] = "3";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr[0] = "4";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr[0] = "5";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr[0] = "6";
dt.Rows.Add(dr);
Repeater1.DataSource = new DataView(dt);
Repeater1.DataBind();
}
The code is almost the same as those in you project, but use the repeater
control instead of Datalist control.
=======================================================
Please apply my suggestion above and let me know if it helps resolve your
problem.
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.
Have a nice day!!
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.