Welcome to WebmasterWorld Guest from 54.90.204.233

Forum Moderators: ocean10000

Message Too Old, No Replies

how can i Fixed header in ASP.NET DataGrid

Fixed header in ASP.NET DataGrid

     
9:31 am on Jul 23, 2009 (gmt 0)

Junior Member

10+ Year Member

joined:Oct 1, 2005
posts:109
votes: 0


here is the code it not working in firefox as we as IE 8

this code only works in ie7

i want to fix the header..i try lot but not working in IE 8

here is the code

---------------

<asp:Panel ID="Panel1" runat="server" ScrollBars="Both" Height="300" Width="100%">
<asp:GridView ID="grdsuspect" runat="server" AllowSorting="True" AutoGenerateColumns="False" CssClass="Grid"
BorderColor="#DDDDDD" BorderStyle="Solid" BorderWidth="0px" CellPadding="3" DataKeyNames="crm_suspects_detail_id"
EmptyDataText="No Data Found" GridLines="None" Height="1px" PageSize="13" Width="97%" UseAccessibleHeader="true">
<EmptyDataRowStyle BorderWidth="1px" CssClass="grdemptyitemstyle" ForeColor="Black"
HorizontalAlign="Center" VerticalAlign="Middle" Width="100px" />
<Columns>
<asp:TemplateField>
<HeaderTemplate>
Date Input
</HeaderTemplate>
<ItemStyle BorderColor="#DDDDDD" BorderWidth="1px" CssClass="grditemstyle" HorizontalAlign="left" />
<HeaderStyle BorderColor="#DDDDDD" BorderWidth="1px" Font-Bold="False" HorizontalAlign="Left"
Width="10%" />
<ItemTemplate>
<asp:Label ID="lbldate" runat="server" CssClass='<%#IIf(DataBinder.Eval(Container.DataItem, "datdiff") >= DataBinder.Eval(Container.DataItem, "no_suspect_reg"), "grditemstylered", "grditemstyle")%>'
Text='<%# Eval("created_date") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>
Company Name
</HeaderTemplate>
<ItemStyle BorderColor="#DDDDDD" BorderWidth="1px" CssClass="grditemstyle" HorizontalAlign="left" />
<HeaderStyle BorderColor="#DDDDDD" BorderWidth="1px" Font-Bold="False" HorizontalAlign="Left"
Width="25%" />
<ItemTemplate>
<asp:LinkButton ID="lnksuscontectEdit" runat="server" CausesValidation="false" CommandArgument='Edit'
CommandName="Edit" CssClass="grditemstyle" Text='<%# Eval("company_name") %>'></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="contactname" HeaderText="Contact Name">
<ItemStyle BorderColor="#DDDDDD" BorderWidth="1px" CssClass="grditemstyle" Font-Bold="False"
HorizontalAlign="Left" VerticalAlign="Top" />
<HeaderStyle BorderColor="#DDDDDD" BorderWidth="1px" Font-Bold="False" HorizontalAlign="Left"
Width="15%" />
</asp:BoundField>
<asp:BoundField DataField="city" HeaderText="Town\City">
<ItemStyle BorderColor="#DDDDDD" BorderWidth="1px" CssClass="grditemstyle" Font-Bold="False"
HorizontalAlign="Left" VerticalAlign="Top" />
<HeaderStyle BorderColor="#DDDDDD" BorderWidth="1px" Font-Bold="False" HorizontalAlign="Left"
Width="10%" />
</asp:BoundField>
<asp:BoundField DataField="postcode" HeaderText="Post Code">
<ItemStyle BorderColor="#DDDDDD" BorderWidth="1px" CssClass="grditemstyle" Font-Bold="False"
HorizontalAlign="Left" VerticalAlign="Top" />
<HeaderStyle BorderColor="#DDDDDD" BorderWidth="1px" Font-Bold="False" HorizontalAlign="Left"
Width="10%" />
</asp:BoundField>
<asp:BoundField DataField="phone" HeaderText="Phone">
<ItemStyle BorderColor="#DDDDDD" BorderWidth="1px" CssClass="grditemstyle" Font-Bold="False"
HorizontalAlign="Left" VerticalAlign="Top" />
<HeaderStyle BorderColor="#DDDDDD" BorderWidth="1px" Font-Bold="False" HorizontalAlign="Left"
Width="20%" />
</asp:BoundField>
<asp:TemplateField>
<HeaderTemplate>
Select
</HeaderTemplate>
<ItemTemplate>
<input name="MyRadioButton" type="radio" value='<%# Eval("crm_suspects_detail_id") %>' />
</ItemTemplate>
<HeaderStyle BorderColor="#DDDDDD" BorderWidth="1px" Font-Bold="False" HorizontalAlign="Center" />
<ItemStyle BorderColor="#DDDDDD" BorderWidth="1px" CssClass="grditemstyle" HorizontalAlign="Center" />
</asp:TemplateField>
</Columns>
<RowStyle BackColor="Transparent" BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" />
<PagerStyle BorderColor="#DDDDDD" BorderStyle="Solid" BorderWidth="0px" CssClass="grditemstyle"
HorizontalAlign="Right" />
<HeaderStyle BackColor="White" CssClass="grdhdrstyle DataGridFixedHeader" Font-Bold="False"
HorizontalAlign="Left" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
</asp:Panel>

-------------------

------------------------

Try
Dim cmdsqlcmd As New SqlCommand("[ts_crm_suspects_details_LoadAll_by_user_id]", MyConn)
cmdsqlcmd.CommandType = CommandType.StoredProcedure
cmdsqlcmd.Parameters.Add(New SqlParameter("@company_name", Data.SqlDbType.NVarChar, 250)).Value = ""
cmdsqlcmd.Parameters.Add(New SqlParameter("@crm_company_country_id", Data.SqlDbType.Int)).Value = "5"
cmdsqlcmd.Parameters.Add(New SqlParameter("@crm_company_group_id", Data.SqlDbType.Int)).Value = Convert.ToInt32(Session("group_id"))
cmdsqlcmd.Parameters.Add(New SqlParameter("@is_deleted", Data.SqlDbType.Bit)).Value = False
cmdsqlcmd.Parameters.Add(New SqlParameter("@flag", Data.SqlDbType.Int)).Value = 2
cmdsqlcmd.Parameters.Add(New SqlParameter("@user_id", Data.SqlDbType.Int)).Value = 3
Dim da = New SqlDataAdapter(cmdsqlcmd)
Dim dt As New DataTable()
da.Fill(dt)
grdsuspect.DataSource = dt
grdsuspect.DataBind()
Session("searchtext") = ""
Catch ex As Exception
''lblError.Text = ex.Message
End Try

------------------

Please help

4:50 pm on July 23, 2009 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 1, 2005
posts:732
votes: 0


The code looks OK to me, but I haven't tested it though. What exactly is the problem with the header?
5:41 pm on July 23, 2009 (gmt 0)

Junior Member

10+ Year Member

joined:Oct 1, 2005
posts:109
votes: 0


when i run this in IE 8 header is not fix

in ie 7 it good

sapose if data come in table but there is heading line like in excel first line is fix (which is heding) rest of the data will be scroll

please help me

7:34 pm on July 23, 2009 (gmt 0)

Administrator

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month

joined:Jan 14, 2004
posts:864
votes: 3


Is IE8 running in standard Compliance Mode or Compatibility mode? This will effect how the generated html will be treated.
4:08 am on July 24, 2009 (gmt 0)

Junior Member

10+ Year Member

joined:Oct 1, 2005
posts:109
votes: 0


in ie 8 standard Compliance Mode
4:14 pm on July 26, 2009 (gmt 0)

Administrator

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month

joined:Jan 14, 2004
posts:864
votes: 3


try viewing it in compatibility view. And see if there is any change. I am guessing your page code isn't validating all the way, and ending up in quirks mode for rendering, which is a pain.

If this is the case run a html validator on the page and try to correct the issues it points out.

7:52 pm on July 27, 2009 (gmt 0)

Administrator

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month

joined:Jan 14, 2004
posts:864
votes: 3


I just read in another thread something that might help you get this working in the short term.

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7">

6:30 am on July 28, 2009 (gmt 0)

Junior Member

10+ Year Member

joined:Oct 1, 2005
posts:109
votes: 0


" <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"> "

thanks, but this is not proper solution

11:20 pm on July 28, 2009 (gmt 0)

Administrator

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month

joined:Jan 14, 2004
posts:864
votes: 3


You are correct it is not a proper solution, but if you were pressed for time it would allow you to solve the problem temporary at least.

Have you tried running the resulting html code though a html validator, and correcting those issues, as much as you can. I have a feeling correcting the html validation errors will correct the IE 8 Rendering issues you are experincing.

12:24 pm on July 29, 2009 (gmt 0)

Junior Member

10+ Year Member

joined:Oct 1, 2005
posts:109
votes: 0


the code is not showing error...please help me
1:24 pm on July 30, 2009 (gmt 0)

New User

5+ Year Member

joined:July 30, 2009
posts:3
votes: 0


I use the real World Grids objects for this, appears to work in IE8 as well

[blogs.msdn.com...]