Click here to Skip to main content
15,892,737 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Frinds

i want fix header horizontol scroll with data vartical scroll and i have done it with this coding


in desing


XML
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="fixheadersrollable._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">
    <title></title>
    <script src="http://code.jquery.com/jquery-1.7.1.min.js" type="text/javascript"></script>
  <script language="javascript" type="text/javascript" >
      function MakeStaticHeader(gridId, height, width, headerHeight, isFooter) {
          var tbl = document.getElementById(gridId);
          if (tbl) {
              var DivHR = document.getElementById('DivHeaderRow');
              var DivMC = document.getElementById('DivMainContent');
              var DivFR = document.getElementById('DivFooterRow');

              //*** Set divheaderRow Properties ****
              DivHR.style.height = headerHeight + 'px';
              DivHR.style.width = (parseInt(width) - 16) + 'px';
              DivHR.style.position = 'relative';
              DivHR.style.top = '0px';
              DivHR.style.zIndex = '10';
              DivHR.style.verticalAlign = 'top';

              //*** Set divMainContent Properties ****
              DivMC.style.width = width + 'px';
              DivMC.style.height = height + 'px';
              DivMC.style.position = 'relative';
              DivMC.style.top = -headerHeight + 'px';
              DivMC.style.zIndex = '1';

              //*** Set divFooterRow Properties ****
              DivFR.style.width = (parseInt(width) - 16) + 'px';
              DivFR.style.position = 'relative';
              DivFR.style.top = -headerHeight + 'px';
              DivFR.style.verticalAlign = 'top';
              DivFR.style.paddingtop = '2px';

              if (isFooter) {
                  var tblfr = tbl.cloneNode(true);
                  tblfr.removeChild(tblfr.getElementsByTagName('tbody')[0]);
                  var tblBody = document.createElement('tbody');
                  tblfr.style.width = '100%';
                  tblfr.cellSpacing = "0";

                  tblfr.border = "0px";
                  tblfr.rules = "none";
                  //*****In the case of Footer Row *******
                  tblBody.appendChild(tbl.rows[tbl.rows.length - 1]);
                  tblfr.appendChild(tblBody);
                  DivFR.appendChild(tblfr);
              }
              //****Copy Header in divHeaderRow****
              DivHR.appendChild(tbl.cloneNode(true));
          }
      }



      function OnScrollDiv(Scrollablediv) {
          document.getElementById('DivHeaderRow').scrollLeft = Scrollablediv.scrollLeft;
          document.getElementById('DivFooterRow').scrollLeft = Scrollablediv.scrollLeft;
      }


      </script>
<script type="text/javascript" onload="setvalue();">

    function getvalue(Scrollablediv) {

        sessionStorage.setItem('pediv1', document.getElementById('DivMainContent').scrollTop);
        sessionStorage.setItem('pediv2', document.getElementById('DivMainContent').scrollLeft);
        OnScrollDiv(Scrollablediv)
    }

    function setvalue() {
//        alert(sessionStorage.getItem('pediv1'));
//        alert(sessionStorage.getItem('pediv2'));
        document.getElementById('DivMainContent').scrollTop = sessionStorage.getItem('pediv1');
        document.getElementById('DivMainContent').scrollLeft = sessionStorage.getItem('pediv2');

    }
      </script>
</head>
<body>
    <form id="form1" runat="server">
    <asp:Button ID="as" runat="server" Text="PostBack" />
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <div id="DivRoot" align="left">
    <div style="overflow: hidden;" id="DivHeaderRow">
    </div>

    <div style="overflow:scroll; " onscroll="getvalue(this)" id="DivMainContent" runat="server" >

      <%--  Place Your GridView Here
<asp:GridView  runat="server"  ID="gridshow" Width="100%" AutoGenerateColumns="False"ShowFooter="True">
         <Columns>
                //...................
         </Columns>
       </asp:GridView>
      --%>
      <asp:GridView ID="aa" runat="server" >
      <Columns>
      <asp:TemplateField>
      <ItemTemplate>
      <asp:Label ID="lable1" runat="server"  Text='<%# Bind("Id") %>' Visible="false"></asp:Label>
           <asp:TextBox ID="txtitem" runat="server"  AutoPostBack="true"></asp:TextBox>

      </ItemTemplate>
      </asp:TemplateField>
      </Columns>
      </asp:GridView>
    </div>

    <div id="DivFooterRow" style="overflow:hidden">
        <asp:SqlDataSource ID="SqlDataSource1" runat="server"
            ConnectionString="<%$ ConnectionStrings:VideoconConnectionString %>"
            SelectCommand="SELECT * FROM [PR_GRNDetails]"></asp:SqlDataSource>
    </div>
</div>

    </form>
</body>
</html>




and code behind


XML
Partial Public Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        ScriptManager.RegisterStartupScript(Page, Me.GetType(), "Key", "<script>MakeStaticHeader('" + aa.ClientID + "', 500, 550 ,  40 ,true,'details'); </script>", False)
        'ScriptManager.RegisterStartupScript(Page, Me.GetType(), "Key1", "<script>MakeStaticHeader('" + aa.ClientID + "', 500, 550 ,  40 ,true,'details1'); </script>", False)
        If Not IsPostBack Then
            aa.DataSource = SqlDataSource1
            aa.DataBind()
            For i As Int16 = 0 To aa.Rows.Count - 1
                CType(aa.Rows(i).FindControl("txtitem"), TextBox).Text = ""
                'CType(aa.Rows(i).FindControl("txtitem"), TextBox).Text = CType(aa.Rows(i).FindControl("lable1"), Label).Text
            Next
        End If
    End Sub


End Class




but problem is that i have a text box in grid and its autopostback true when it is post back thanit have multiple entry with comma 23,23,23 pls help me
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900