I'm using a Repeater to create a grid but the grid doesn't fill the width of the screen. It cut offs and leaves blank spaces between the end of the repeater and the border on the right.
I tried setting the last <td> tag to width:100% which did make the line go all the way across but it caused all the other columns to move over to the far left and ruined the layout.
Code:
<tr>
<td style="border-left:1px solid; border-right:1px solid; height:400px" >
<asp:Repeater ID="rptHazDetails" runat="server">
<HeaderTemplate>
<table border="1">
<tr style="border-bottom:1px solid;">
<td>
UN Number, </br>
Proper Shipping Name
</td>
<td style="padding:5px">
Class , </br>
Packing Group
</td>
<td style="padding:5px">
Pieces
</td>
<td style="padding:5px">
Tunnel Code
</td>
<td style="padding:5px">
Gross KG
</td>
<td style="padding:5px">
Net KG
</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr style="border-bottom:1px solid;">
<td style="padding:5px;">
<asp:Label ID="lblUNNumber" runat="server" Text='<%# Eval("UnNumber") %>' /> </br>
<asp:Label ID="lblProper" runat="server" Text='<%# Eval("Packages") %>' />
</td>
<td style="padding:5px;">
<asp:Label ID="lblClass" runat="server" Text='<%# Eval("IMOClass") %>' /> </br>
<asp:Label ID="lblPacking" runat="server" Text='<%# Eval("IMOPage") %>' />
</td>
<td style="padding:5px;">
<asp:Label ID="lblPieces" runat="server" Text='<%# Eval("PieceBreakDown") %>' />
</td>
<td style="padding:5px;">
<asp:Label ID="lblTunnelCode" runat="server" Text='<%# Eval("TunnelCode") %>' />
</td>
<td style="padding:5px;">
<asp:Label ID="lblGrossWeight" runat="server" Text='<%# Eval("GrossWeight","{0:0.##}") %>' />
</td>
<td style="padding:5px;">
<asp:Label ID="lblNetWeight" runat="server" Text='<%# Eval("NetWeight","{0:0.##}") %>' />
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</td>
</tr>
I just want to border lines to reach all the across the screens and don't leave a gap.
I set:
table {
width: 100%;
}
This way the table will cover the entire window. I then can choose to give each column a different width in px or %, the best way is using bootstrap classes. So include in your header
Then you can set a class for example col-md-4 for giving that column a span of 4 columns, you can also hide the column for sm screens and do other effects. Go and check
http://getbootstrap.com/css/#grid
Or ask me more informations
Fabrizio Bertoglio
Related
i am trying to figure out how to fix the header row with in the repeater using asp.net. When trying to put position:fixed; in the tr tag. It seems to fix it but it becomes smaller in size and doesn't work with the rest of the table.
any hints or help in the right direction would help significantly!
thanks
<div class="form-panel" style="font-size: small; text-align: left;">
<div class="header">
<div class="contentRestriction" style="height: 22px">
Action Bulletin Exception
<asp:button id="addException" text="Add Exception" runat="server" style="float: right; margin-right: 20px" onclick="addExceptions" />
</div>
</div>
<div class="commands">
<div class="contentRestriction" style="overflow-y: scroll; width: 100%; height: 185px">
<asp:repeater id="repException" runat="server" datasourceid="SP_AB_BULLETIN_EXCEPTION">
<HeaderTemplate>
<div class="form-panel" style="font-size: small;">
<table class="notepad-table" cellpadding="2" cellspacing="0" width="100%" >
<tr style="background-color: #eeeeee; font-weight: bold; ">
<td>Date Time From</td>
<td>Date Time To</td>
<td>Status</td>
<td>Last Modified</td>
<td>Last Modified By</td>
<td>Action</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr id="tr1" runat="server">
<td>
<asp:Literal ID="Literal1" runat="server" Text='<%# Eval("EFTV_FROM") %>' />
</td>
<td>
<asp:Literal ID="Literal2" runat="server" Text='<%# Eval("EFTV_TO") %>' />
</td>
<td>
<asp:Literal ID="Literal3" runat="server" Text='<%# Eval("AB_STATUS1") %>' />
</td>
<td>
<asp:Literal ID="Literal4" runat="server" Text='<%# Eval("LAST_MOD_DATE") %>' />
</td>
<td>
<asp:Literal ID="Literal6" runat="server" Text='<%# Eval("UserName") %>' />
</td>
<td>
<asp:Button ID="editException" Text="Edit" runat="server" CommandName="EXID" CommandArgument='<%# Eval("EX_ID") %>' OnCommand="editException" />
<asp:Button ID="deleteException" Text="Delete" runat="server" CommandName="EXID" CommandArgument='<%# Eval("EX_ID") %>' OnCommand="deleteException" />
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</div>
</FooterTemplate>
</asp:Repeater>
</div>
</div>
</div>
To get the fixed header effect you can make two small changes to your code.
1) Paste the following style rules in the <head> section of your page:
<style type="text/css">
table tbody, table thead {
display: block;
}
table tbody {
overflow: auto;
height: 100px;
}
th, td {
width: 150px;
}
</style>
2) Replace your <div class="commands"> with the one below:
<div class="commands">
<asp:Repeater ID="repException" runat="server" DataSourceID="SP_AB_BULLETIN_EXCEPTION">
<HeaderTemplate>
<div class="form-panel" style="font-size: small;">
<table class="notepad-table" cellpadding="2" cellspacing="0">
<thead>
<tr style="background-color: #eeeeee; font-weight: bold;">
<th>Date Time From</th>
<th>Date Time To</th>
<th>Status</th>
<th>Last Modified</th>
<th>Last Modified By</th>
<th>Action</th>
</tr>
</thead>
<tbody>
</HeaderTemplate>
<ItemTemplate>
<tr id="tr1" runat="server">
<td>
<asp:Literal ID="Literal1" runat="server" Text='<%# Eval("EFTV_FROM") %>' />
</td>
<td>
<asp:Literal ID="Literal2" runat="server" Text='<%# Eval("EFTV_TO") %>' />
</td>
<td>
<asp:Literal ID="Literal3" runat="server" Text='<%# Eval("AB_STATUS1") %>' />
</td>
<td>
<asp:Literal ID="Literal4" runat="server" Text='<%# Eval("LAST_MOD_DATE") %>' />
</td>
<td>
<asp:Literal ID="Literal6" runat="server" Text='<%# Eval("UserName") %>' />
</td>
<td>
<asp:Button ID="editException" Text="Edit" runat="server" CommandName="EXID" CommandArgument='<%# Eval("EX_ID") %>' OnCommand="editException" />
<asp:Button ID="deleteException" Text="Delete" runat="server" CommandName="EXID" CommandArgument='<%# Eval("EX_ID") %>' OnCommand="deleteException" />
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</tbody>
</table>
</div>
</FooterTemplate>
</asp:Repeater>
</div>
Output:
I am creating a webpage which has been divide into two sides. On the left there is an image and on the right there can be various user inputs. I put the image into a table cell with float left and the inputs into a cell and float right.
Everything look like what I expect until I add a grid on the right using
<tr>
<asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1">
</asp:GridView>
</tr>
Then the alignment of the contents on the right all move to the bottom of the left hand side. Can anyone can help me on this how to make it stick back to the right?
Here is my mark-up
<table id="leftT">
<tr id ="table_left" >
<td>
<asp:Image ID="Image1" runat="server" Height="356px" ImageUrl="~/Image/search.jpg" Width="200px" style="vertical-align:text-top"/>
</td>
</tr>
</table>
<table id ="rightT">
<tr>
<td>
<asp:Label ID="lblUserName" runat="server" Text="Label"></asp:Label>
</td>
<td>
<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource1" DataTextField="USERNAME" DataValueField="USERNAME">
<asp:ListItem></asp:ListItem>
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:SOConnectionString %>" ProviderName="<%$ ConnectionStrings:SOConnectionString.ProviderName %>" SelectCommand="SELECT USERNAME FROM USERMASTER WHERE USERSTATUS = 1 AND USERACCESSRIGHTS = 'Non-Administrator'"></asp:SqlDataSource>
</td>
<td>
<asp:Label ID="lblCreateOnM" runat="server" Text="Label"></asp:Label>
</td>
<td>
<asp:Label ID="lblCreateOn" runat="server" Text="Label"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblDate" runat="server" Text="Label"></asp:Label>
</td>
<td><asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
<asp:TextBox ID="txtDate" runat="server" Enabled="False"></asp:TextBox>
<asp:Calendar ID="Calendar1" runat="server" OnSelectionChanged="Calendar1_SelectionChanged"></asp:Calendar></td>
<td>
<asp:Label ID="lblUpdateOnM" runat="server" Text="Label"></asp:Label>
</td>
<td>
<asp:Label ID="lblUpdateOn" runat="server" Text="Label"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblTask" runat="server" Text="Label"></asp:Label>
</td>
<td>
<asp:DropDownList ID="DropDownList2" runat="server" DataSourceID="SqlDataSource2" DataTextField="TASKNAME" DataValueField="TASKNAME">
<asp:ListItem></asp:ListItem>
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:SOConnectionString %>" ProviderName="<%$ ConnectionStrings:SOConnectionString.ProviderName %>" SelectCommand="SELECT DISTINCT TASKNAME FROM TASKMASTER"></asp:SqlDataSource>
</td>
<td>
<asp:Label ID="lblUpdateByM" runat="server" Text="Label"></asp:Label>
</td>
<td>
<asp:Label ID="lblUpdateBy" runat="server" Text="Label"></asp:Label>
</td>
</tr>
</table>
Here The mistake you are doing is, you are creating two tables one below the other.Instead take only one table and two columns and places all the controls in these two columns as shown below
ex-
<table>
<tr>
<td id='Left_id'>
//Put all the left controls here
</td>
<td id='Right_id'>
//Put some controls here if required
<table>
<tr>
<td>
//some Controls Here
</td>
</tr>
</table>
</td>
</tr>
</table>
i try to add dropdown in repeater it shows me drodown above in table where as i want to show in status column
code in html
<div class="CSSTableGenerator">
<table border="0" width="100%" cellpadding="0"
cellspacing="0" id="results">
<asp:Repeater ID="Repeater2" OnItemCommand="Repeater2_ItemCommand" runat="server">
<HeaderTemplate>
<tr>
<td>
DocumentID
</td>
<td>
DocName
</td>
<td>
File Name
</td>
<td>
Document
</td>
<td>
Department
</td>
<td>
Status
</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<asp:Label Id="DocId" runat="server"></asp:Label>
<%#DataBinder.Eval(Container.DataItem, "DocID")%>
</td>
<td>
<asp:Label Id="DocName" runat="server"></asp:Label>
<%#DataBinder.Eval(Container.DataItem, "DocName")%>
</td>
<td>
<asp:Label Id="Uploadfile" runat="server"></asp:Label>
<%#DataBinder.Eval(Container.DataItem, "Uploadfile")%>
</td>
<td>
<asp:Label Id="DocType" runat="server"></asp:Label>
<%#DataBinder.Eval(Container.DataItem, "DocType")%>
</td>
<td>
<asp:Label Id="DepType" runat="server"></asp:Label>
<%#DataBinder.Eval(Container.DataItem, "DepType")%>
</td>
<td>
<asp:Label ID="Label1" runat="server"
Text='<%# Eval("ApproveID") %>' Visible = "false" />
<%#DataBinder.Eval(Container.DataItem, "ApproveID")%>
</td>
</tr>
<asp:Label ID="lblCountry" runat="server"
Text='<%# Eval("ApproveID") %>' Visible = "false" />
<asp:DropDownList ID="DropDownList4" runat="server"
EnableViewState="true" class="vpb_dropdown"
DataTextField="ApproveType"
DataValueField="ApproveID" AutoPostBack="true"
OnSelectedIndexChanged="DropDownList4_SelectedIndexChanged">
<asp:ListItem Text="Pending" selected="selected"
Value="3"></asp:ListItem>
<asp:ListItem Text="Approve"
Value="1"></asp:ListItem>
<asp:ListItem Text="Reject"
Value="2"></asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:Repeater>
</table>
<asp:Label ID="apfi" runat="server" Text="Label"></asp:Label><br />
<asp:Button ID="Button4" runat="server" Text="Button" onclick="Button4_Click" />
</div>
</div>
</center>
</div>
pleae have a look image below how i solve this ...where is mistake?
but it shows me like this
image
The mistake is that your DropDownList (and a Label) are between the table and tr elements, which is invalid HTML. The result client-side would be something like this:
<table>
<tr>
<td>...</td>
</tr>
<span>...</span>
<select>
<option>...</option>
</select>
</table>
There's no way to correctly render that because span and select aren't table row elements.
As for how to fix this, that entirely depends on how you want those elements to display. What you've attempted isn't a meaningful layout, so what is the layout you're looking for?
For example, if you want those elements to display in a table cell at the end of the row, you need to add a cell for them:
<table>
<tr>
<td>...</td>
<td>
<span>...</span>
<select>
<option>...</option>
</select>
</td>
</tr>
</table>
If you want them to display outside the table (maybe to the right of it?) then they'd need to be outside the table and you can use CSS to position them. (Alignment would be tricky, though. If they're logically part of the table, which they seem to be given that they're in its repeater, then they should be part of the table itself.)
Table structures have to be structured like a table.
(Note: Any time you have rendering issues like this, the first thing you should do is validate your markup. That would have identified specifically which parts are invalid and referenced the HTML specifications which define those parts.)
I want to align ' : ' vertically, how to do that?
<td>
<b>ID</b>:<asp:Label ID="ID0" runat="server" Text='<%# Bind("ID") %>'></asp:Label>
<br></br>
<b>Name</b>:<asp:Label ID="Name0" runat="server" Text='<%# Bind("Name") %>'></asp:Label>
<br></br>
<b>Age</b>:<asp:Label ID="Age0" runat="server" Text='<%# Bind("Age") %>'></asp:Label>
<br></br>
<b>Height</b>:<asp:Label ID="Height0" runat="server" Text='<%# Bind("Height") %>'></asp:Label>
<br></br>
<b>Education</b>:<asp:Label ID="Education0" runat="server" Text='<%# Bind("Education") %>'></asp:Label>
</td>
</tr>
I simply split the fields and values into columns. Then all you have to do is right-align the field table-cell.
CSS:
.left-column
{
text-align: right;
font-weight: bold;
}
HTML:
<table>
<tr>
<td>
<table>
<tr>
<td class="left-column">
ID:
</td>
<td>
<asp:Label ID="ID0" runat="server" Text='<%# Bind("ID") %>' />
</td>
</tr>
<tr>
<td class="left-column">
Name:
</td>
<td>
<asp:Label ID="Name0" runat="server" Text='<%# Bind("Name") %>' />
</td>
</tr>
<tr>
<td class="left-column">
Age:
</td>
<td>
<asp:Label ID="Age0" runat="server" Text='<%# Bind("Age") %>' />
</td>
</tr>
<tr>
<td class="left-column">
Height:
</td>
<td>
<asp:Label ID="Height0" runat="server" Text='<%# Bind("Height") %>' />
</td>
</tr>
<tr>
<td class="left-column">
Education:
</td>
<td>
<asp:Label ID="Education0" runat="server" Text='<%# Bind("Education") %>' />
</td>
</tr>
</table>
</td>
</tr>
</table>
You have invalid markup as colon(:) doesn't inside b or asp:Label.
change
<b>ID</b>:<asp:Label ID="ID0" runat="server" Text='<%# Bind("ID") %>'></asp:Label>
to this
<b>ID :</b><asp:Label ID="ID0" runat="server" Text='<%# Bind("ID") %>'></asp:Label>
You'll need to use elements that have display:inline-block then you can use vertical-align:middle
EDIT
I misunderstood the question. You could set a minimum width on your <b> tags, but it's not fully cross-browser:
<style>
p b { min-width: 50px; display:inline-block; }
</style>
<p><b>Foo</b>:</p>
<p><b>Bar</b>:</p>
However, as you're using a table anyway, I'd suggest using the table itself to keep things aligned
How do I prevent a table from wrapping when it is inside of an outer table cell?
Have a look at the simplified example at the bottom of my question.
My aspx-tablerow:
<tr runat="server" id="trButtons">
<td align="left" colspan="9" valign="top" style="white-space:nowrap"><br />
<asp:Button ID="btnImeiLookup" OnClick="btnImeiLookupClick" runat="server" ValidationGroup="VG_RMA_LOOKUP" CausesValidation="true" Text="lookup IMEI" ToolTip="lookup IMEI and check if RMA-Number can be generated" Width="120px" />
<asp:Button ID="BtnEdit" CommandName="Edit" CommandArgument='<%# Eval("idRMA")%>' ValidationGroup="VG_RMA_SAVE" runat="server" CausesValidation="false" Text="Edit" ToolTip="edit" Width="120px" />
<asp:Button ID="BtnAdd" runat="server" CommandName="Add" CausesValidation="false" Text="Add new" Width="130px" ToolTip="add new" />
<asp:Button ID="BtnDelete" runat="server" CommandName="Delete" CommandArgument='<%# Eval("idRMA")%>' CausesValidation="true" Text="Delete" Width="120px" ToolTip="delete" OnClientClick="return confirm('do you really want to delete this RMA?')" />
<uc4:RmaPrinterView ID="RmaPrinterView1" Visible="true" runat="server" />
</td>
</tr>
RmaPrinterView1 is an ASP.Net Usercontrol:
<table cellpadding="0" cellspacing="0">
<tr>
<td>
<input type="button" style="width:120px; white-space:nowrap" onclick="javascript:$('#TblPrinterView').jqprint();" value="Print" title="Print" />
</td>
</tr>
<tr>
<td>
<table id="TblPrinterView" style="display:none">
<tr>
<td style="width:100px;white-space:nowrap">
<asp:Label ID="LblRmaNumberDesc" runat="server" Text="RMA-Number:"></asp:Label>
</td>
<td>
<asp:Label ID="LblRmaNumber" runat="server" Text="xxxxxxxxxxxxxx"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="LblImeiDesc" runat="server" Text="IMEI:"></asp:Label>
</td>
<td>
<asp:Label ID="LblImei" runat="server" Text="xxxxxxxxxxxxxx"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="LblModelDesc" runat="server" Text="Model:"></asp:Label>
</td>
<td>
<asp:Label ID="LblModel" runat="server" Text="xxxxxxxxxxxxxx"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="LblSiDpyDesc" runat="server" Text="SI/DPY:"></asp:Label>
</td>
<td>
<asp:Label ID="LblSiDpy" runat="server" Text="xxxxxxxxxxxxxx"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="LblSymptomCodesDesc" runat="server" Text="Symptoms:"></asp:Label>
</td>
<td>
<asp:Label ID="LblSymptomCodes" runat="server" Text="xxxxxxxxxxxxxx"></asp:Label>
</td>
</tr>
</table>
</td>
</tr>
</table>
As you can see, the Usercontrol with the inner table is wrapped:
I know that I should avoid table layout, but I needed a fast working solution ;-)
EDIT: a simplified sample that is also wrapping:
<table>
<tr>
<td style="white-space:nowrap">
<input type="button" value="b1" />
<input type="button" value="b2" />
<input type="button" value="b3" />
<table>
<tr>
<td style="white-space:nowrap"><input type="button" value="in table" /></td>
</tr>
</table>
</td>
</tr>
</table>
UPDATE:
The solution - as Jeroen mentioned - was to make the table an inline element with style="display: inline". The next problem was that I used an ASP.Net UpdatePanel inside the UserControl which is normally rendered as a Div. So the next block-element that causes my table to wrap. I only needed to set the UpdatePanel's RenderMode to Inline what causes it to be rendered as Span.
If the css white-space does not work, you can try to add nowrap="nowrap" to your td, just like you added valign="top".
Very ugly, but it should work.
Edit: Ah, now I see: A table is a block-level element so it will always go to a new line unless you make it an inline-element or float it.
table tr td {
white-space: nowrap;
}
You've put the table at odds with itself. It is set to finite pixel count and yet you don't want to wrap once that's exceeded. You might attempt:
white-space: nowrap;
overflow: hidden;