|
-
Sep 14th, 2010, 04:49 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] gridview top position
Hi team, can we fix the gridview position with top:0px in table row.

Code:
<asp:GridView ID="GridView1" runat="server" Width="95%" AllowPaging="True" AutoGenerateColumns="False" GridLines="None" PageSize="10" CssClass="grid_top">
....
</gridview>
CSS
Code:
.grid_top{
top:0px;
}
-
Sep 14th, 2010, 05:45 AM
#2
Re: gridview top position
Hey,
Can you show the markup for the rest of the page?
What other elements does the GridView live in?
Gary
-
Sep 14th, 2010, 07:16 AM
#3
Thread Starter
Fanatic Member
Re: gridview top position
I hope this will help.
Code:
<td colspan="8" rowspan="4" style="background-image: url(_images/subcontracts2_18.jpg); background-repeat: no-repeat; height:488px">
<form id="gridviewform" runat="server" onreset ="return confirm('Do you really want to clear the form?'); ">
<div id="gridviewdiv" >
<asp:GridView ID="GridView1" runat="server" Width="95%" AllowPaging="True" AutoGenerateColumns="False" GridLines="None" PageSize="10" CssClass="grid_top">
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#999999" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<asp:HyperLinkField DataNavigateUrlFields="ID" DataNavigateUrlFormatString="contract.aspx?id={0}"
Text="<img src='_Images/edit.gif' alt='Edit' border='0'/>" />
<asp:TemplateField HeaderText="PTS No">
<ItemTemplate><asp:Label ID="lblptsno" runat="server"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Dated">
<ItemTemplate><asp:Label ID="lbldated" runat="server"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Project">
<ItemTemplate><asp:Label ID="lblproject" runat="server"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="For">
<ItemTemplate><asp:Label ID="lblfor" runat="server"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText ="Subcontractor">
<ItemTemplate>
<asp:Label ID="lblsubcontractor" runat="server"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
<div id="filterdiv" style="position: absolute; top:520px; left: 35px; ">
<br />
<br />
<table>
<tr>
<td style="width: 100px">
<asp:Label ID="Label1" runat="server" Text="Search on"></asp:Label></td>
<td style="width: 100px">
<asp:TextBox ID="TextBox1" runat="server" CssClass="textbox_style" Width="349px"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 100px">
<asp:Label ID="Label2" runat="server" Text="Criteria"></asp:Label></td>
<td style="width: 100px">
<asp:DropDownList ID="DropDownList1" runat="server" CssClass="textbox_style" Width="356px">
<asp:ListItem>-- select from the list --</asp:ListItem>
<asp:ListItem>By PTS No</asp:ListItem>
<asp:ListItem>By Project</asp:ListItem>
<asp:ListItem>By Subcontractor</asp:ListItem>
</asp:DropDownList></td>
</tr>
<tr>
<td style="width: 100px">
</td>
<td style="width: 100px">
<input id="clearButton" type="reset" value="Clear" class="button_style" style="width: 60px; height: 20px;" /><asp:Button ID="Button1" runat="server" Text="Button" CssClass="button_style" Width="66px" /></td>
</tr>
</table>
</div>
</form>
</td>
-
Sep 14th, 2010, 10:53 AM
#4
Re: gridview top position
Ok, this first question would be...
Is there a reason why you are using tables to layout your page? This really isn't the best way to go about it.
Secondly, if you are struggling with layout, fire up FireBug within FireFox, and look at the HTML that is generated. You can then alter the HTML and CSS on the fly to get it to look how you want, and then you can implement this within your code.
Gary
-
Sep 14th, 2010, 11:08 AM
#5
Re: gridview top position
did your tried something like:
Code:
#gridviewdiv{margin:0 0 0 0;}
or even
Code:
#gridviewdiv{margin:-2px 0 0 0;}
or something this? those your table td cells has padding ? if so remove the padding
* Rate It  If you Like it
__________________________________________________________________________________________
" Programming is like sex: one mistake and you’re providing support for a lifetime."
Get last SQL insert ID 
-
Sep 15th, 2010, 09:02 AM
#6
Re: gridview top position
Set the vertical alignment attribute of the TD tag. By default it is middle.
<td colspan="8" rowspan="4" valign="top"
The equivalent CSS style is
vertical-align:top
-
Sep 15th, 2010, 10:11 AM
#7
Thread Starter
Fanatic Member
Re: gridview top position
@brucevde and @motil
its work perfectly with
Code:
vertical-align:top;
@gep, @brucevde and @motil
Thanks for the note. But the photoshop used a table layout when you save the sliced image. But i would try doing that through divs. Here is my layout (sorry for the colour as it just a random selection from the palette), each colour is equivalent to a slice.
I would appreciate if you find sometime to layout through div.

Uploaded with ImageShack.us
_____
learning in vbforums
-
Sep 15th, 2010, 03:46 PM
#8
Re: gridview top position
I little trick that I learnt recently is to consider everything as columns. Looking at the layout you have there, I see 6 columns. Granted, some of these columns span over columns, but at the heart, you have a 6 column layout. Once you start thinking like that, it is easy to start laying out your pages.
Gary
-
Sep 16th, 2010, 03:50 AM
#9
Thread Starter
Fanatic Member
Re: gridview top position
hey,
im planning of creating div for each slice and form the desired layout. is that the correct/standard way using divs? Roughly the markup will look like:
Code:
<form id="form1" runat="server">
<div id="logo" > </div>
<div style="float:left" onmouseout="MM_swapImgRestore()"
onmouseover="MM_swapImage('home','','images/hover/home.jpg',1)">
<img id="home" src="images/home.jpg" alt="home" />
</div>
<div style="float:left" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('contract','','images/hover/contract_main1.jpg',1)">
<img id="contract" src="images/contract_main.jpg" alt="contract"/>
</div>
<div style="float:left" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('adv','','images/hover/advance_payment_bank_guarantee.jpg',1)">
<img id="adv" src="images/advance_payment_bank_guarantee.jpg" alt="adv"/>
</div>
<div style="float:left">
<img id="body" alt="adv" src="images/body.jpg" />
</div>
</form>
One thing more, do i need to always mention the slice height and width?
Learn something new every .001 second. 
-
Sep 16th, 2010, 04:12 AM
#10
Re: gridview top position
You don't need to to always set the height / width of an element but when floating div you should set its width since it fix a lot of IE6/IE7 and also IE8 CSS bugs.
* Rate It  If you Like it
__________________________________________________________________________________________
" Programming is like sex: one mistake and you’re providing support for a lifetime."
Get last SQL insert ID 
-
Sep 16th, 2010, 04:29 AM
#11
Re: gridview top position
this is how i would build your header :
html code:
css code
Code:
<style type="text/css">
#wrapper{width:960px;margin:0px auto;border:1px solid black;}
#Header{}
#logo{background:green;float:left;width:200px;height:60px;}
#blank{float:left;background:red;width:560px;height:60px;}
#misc{float:left;background:blue;height:60px;width:200px;}
#tools{background:black;color:#fff;height:30px}
#WebTitles{background:yellow;height:30px;}
</style>
Code:
<div id="wrapper">
<div id="Header">
<div id="logo">
LOGO
</div>
<div id="blank">
BLANK
</div>
<div id="misc">
<div id="tools">
TOOLS
</div>
<div id="WebTitles">
Web Titles
</div>
</div>
</div>
</div>
* Rate It  If you Like it
__________________________________________________________________________________________
" Programming is like sex: one mistake and you’re providing support for a lifetime."
Get last SQL insert ID 
-
Sep 16th, 2010, 05:29 AM
#12
Thread Starter
Fanatic Member
Re: gridview top position
@motil Can you please tell me why there is a need to have a header and misc div when I will get the same layout.
Many thanks.
Last edited by jlbantang; Sep 16th, 2010 at 06:59 AM.
Learn something new every .001 second. 
-
Sep 16th, 2010, 07:19 AM
#13
Re: gridview top position
Part of a good CSS layout is the ability to easily make changes to the layout by only changing the CSS. Even though you are not doing anything with a misc DIV just now, it might be the case that you want to do something with it later on. By putting it in just now, and specifying a header CSS class for it, means that if you need to, you can just alter the CSS.
Gary
-
Sep 16th, 2010, 08:28 AM
#14
Re: gridview top position
as Gary wrote you should keep your css organized and clean and it always a good idea to keep elements inside containers,
here is your full layout:
css
Code:
<style type="text/css">
#wrapper{width:960px;margin:0px auto;border:1px solid black;}
#Header{}
#logo{background:green;float:left;width:200px;height:60px;}
#blank{float:left;background:red;width:560px;height:60px;}
#misc{float:left;background:blue;height:60px;width:200px;}
#tools{background:black;color:#fff;height:30px}
#WebTitles{background:yellow;height:30px;}
#nav {background:gray;text-align:left;height:30px;}
#nav div{float:left;color:#fff;width:135px;border:1px solid black;text-align:center;height:30px;line-height:30px;}
#nav div a{color:#fff;display:block;}
#MainContent{float:left;width:760px;background:#38fa4a;height:300px;}
#SideBar {float:right;width:200px;}
#Box1,#Box2{height:150px;background:gray;}
.BoxHeader{background:orange;height:20px;text-align:center;}
#footer {background:#809dfb;text-align:center;}
.clear{clear:both;}
</style>
html:
Code:
<div id="wrapper">
<div id="Header">
<div id="logo">
LOGO
</div>
<div id="blank">
BLANK
</div>
<div id="misc">
<div id="tools">
TOOLS
</div>
<div id="WebTitles">
Web Titles
</div>
</div>
<div class="clear"></div>
</div>
<div id="nav">
<div><a href="">Menu 1</a></div>
<div><a href="">Menu 2</a></div>
<div><a href="">Menu 3</a></div>
<div><a href="">Menu 4</a></div>
<div><a href="">Menu 5</a></div>
<div><a href="">Menu 6</a></div>
<div>Blank</div>
</div>
<div id="content">
<div id="MainContent">
Dynamic Web Content
</div>
<div id="SideBar">
<div id="Box1">
<div class="BoxHeader">Label 1</div>
<div class="BoxContent">Some Text</div>
</div>
<div id="Box2">
<div class="BoxHeader">Label 1</div>
<div class="BoxContent">Some Text</div>
</div>
</div>
</div>
<div id="footer">
Footer
</div>
</div>
a couple of things i should mention:
now days when you have a link list the best idea is to make it with the UL element but one of the problems with that method is that you cant set the width of inline element (you set the display of the li value to "inline") so you ending up with uneven list of links. you can fix that by setting the display of the li to "inline-block' but again our friends from IE6 no support this property so in the end of the day you must go back to floating divs, just remember that if you wish to create list of links and you don't mind the width of each link use the ul tag, it's very clean.
i also set the height of the main container (#MainContent) to 300px, but you should remove it and let the height resize to the document length.
change the css as you wish i think you have enough to go from here
good luck with your work!
* Rate It  If you Like it
__________________________________________________________________________________________
" Programming is like sex: one mistake and you’re providing support for a lifetime."
Get last SQL insert ID 
-
Sep 16th, 2010, 11:03 AM
#15
Thread Starter
Fanatic Member
Re: gridview top position
that is great, I appreciated it most. another interesting markup you have is this:
Code:
<div class="clear"></div>
does it make any difference to take it out? why you did not use that tag across all div main groups (nav, content and footer)
Learn something new every .001 second. 
-
Sep 16th, 2010, 11:57 AM
#16
Re: gridview top position
the clear class use the "clear:both" property it makes sure the "float" property will cleared, some browser cause to the lower divs to collapse if you don't clear the float.
final tip: make sure to keep testing your website in different browsers since some css rules are differ between one browser to another, you'll found out soon enough that firefox,chrome,opera and safari almost always obey the CSS rules but IE6,IE7 and also IE8 (which is a bit better then 6,7) are almost always has their own rules.
and from the short ride i had on IE9 (beta) last night i saw it has it's own issues which i hope they'll fix until the release.
* Rate It  If you Like it
__________________________________________________________________________________________
" Programming is like sex: one mistake and you’re providing support for a lifetime."
Get last SQL insert ID 
-
Sep 17th, 2010, 02:11 AM
#17
Re: gridview top position
 Originally Posted by motil
final tip: make sure to keep testing your website in different browsers since some css rules are differ between one browser to another, you'll found out soon enough that firefox,chrome,opera and safari almost always obey the CSS rules but IE6,IE7 and also IE8 (which is a bit better then 6,7) are almost always has their own rules.
and from the short ride i had on IE9 (beta) last night i saw it has it's own issues which i hope they'll fix until the release.
This is great advice.
One way to easily test your site across lots of different browsers is here:
http://browsershots.org/
Point it at your site, and it will take screenshots of it in lots of different browsers. Then you can do a visual check to ensure that things are looking the same.
Gary
-
Sep 18th, 2010, 01:55 AM
#18
Thread Starter
Fanatic Member
Re: gridview top position
I'l have to put all bits and pieces to work. See all you in next post.
Learn something new every .001 second. 
-
Sep 20th, 2010, 02:01 AM
#19
Re: gridview top position
 Originally Posted by jlbantang
I'l have to put all bits and pieces to work. See all you in next post.
We'll be waiting
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|