You must Sign In to post a response.
  • Category: ASP.NET

    Need scroll for a gridview using asp.net using c#. if i show the data in gridview i need

    need scroll for a gridview using asp.net using c#. if i show the data in gridview i need bar .
  • #762243
    Hi

    You can copy paste this code in your page for scrolling Gridview C#

    Client Side


    <div id="div1" style="overflow:auto; width:400px;height:150px;">
    <asp:GridView ID="GrdData1" runat="server" AutoGenerateColumns="false">
    <Columns>
    <asp:BoundField DataField = "EMPID" HeaderText = "EMPID ID" />
    <asp:BoundField DataField = "EMPNAME" HeaderText = "EMPNAME" />

    <asp:TemplateField ItemStyle-Width = "30px" HeaderText = "EMPID">
    <ItemTemplate>
    <asp:LinkButton ID="lnkEditRecord" runat="server" Text = "Edit" OnClick="lnkEditRecord_Click"></asp:LinkButton>
    </ItemTemplate>
    </asp:TemplateField>
    </Columns>
    </asp:GridView>
    </div>



    Server Side


    DataTable dt = new DataTable();
    dt.Columns.Add("EMPID");
    dt.Columns.Add("EMPNAME");
    DataRow dr;
    dr = dt.NewRow();
    dr[0] = 1001;
    dr[1] = "Jehovah";
    dt.Rows.Add(dr);

    dr = dt.NewRow();
    dr[0] = 1001;
    dr[1] = "Elroie";
    dt.Rows.Add(dr);

    dr = dt.NewRow();
    dr[0] = 1001;
    dr[1] = "ELSHADAI";
    dt.Rows.Add(dr);
    dr = dt.NewRow();
    dr[0] = 1001;
    dr[1] = "Jayakumar";
    dt.Rows.Add(dr);
    dr = dt.NewRow();
    dr[0] = 1001;
    dr[1] = "ELOHIM";
    dt.Rows.Add(dr);
    dr = dt.NewRow();
    dr[0] = 1001;
    dr[1] = "Jayakumar";
    dt.Rows.Add(dr);


    dr = dt.NewRow();
    dr[0] = 1001;
    dr[1] = "Jayakumar";
    dt.Rows.Add(dr);


    GrdData1.DataSource = dt;
    GrdData1.DataBind();



    I have attached Image given below.

    Name : Dotnet Developer-2015
    Email Id :kumaraspcode2009@gmail.com

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.

    Delete Attachment

  • #762263
    Hello Selvi,

    Refer the below code :

    http://www.aspsnippets.com/Articles/Add-vertical-scrollbar-to-GridView-in-ASPNet.aspx

    http://www.aspsnippets.com/Articles/Scrollable-GridView-with-Fixed-Headers-in-ASP.Net.aspx

    http://www.codeproject.com/Articles/614041/GridView-with-Fixed-Header-and-Scroll-Bar

    http://www.aspnettutorials.com/tutorials/controls/gridviewscroll-aspnet2-csharp/


    Hope this will work for you.

    Regards,
    Nirav Lalan
    DNS Gold Member
    "Failure is the path of least persistence"

  • #762264
    Hi selvi,

    using Jquery you can achieve this with simple steps,

    Add JQuery plugins
    1) Jquery1.8.2.min.js
    2)jquery1.9.1.min.js
    3)gridviewscroll.min.js

    and wrote below lines of code in client side


    <script type="text/javascript" src="../Scripts/jquery1.8.2.min.js"></script>
    <script type="text/javascript" src="../Scripts/jquery1.9.1.min.js"></script>
    <script type="text/javascript" src="../Scripts/gridviewScroll.min.js"></script>
    <script type="text/javascript">
    $(document).ready(function () {
    gridviewScroll();
    });

    function gridviewScroll() {
    $('#<%=GV.ClientID%>').gridviewScroll({
    width: 1100,
    height: 200
    });
    }
    </script>



    If you want to change the width and height then you can change it accordingly.

    This will help you to scroll the gridview with fixed headers.

    Refer below link for more information.
    Here, I explain clearly with step by step
    http://www.dotnetspider.com/resources/45021-Scrollable-GridView-using-JQuery.aspx

    Hope this will helpful to you...

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/

  • #762277

    hi

    try this


    <td><asp:TextBox ID="txtdisrs" runat="server"></asp:TextBox></td></tr>
    <tr><td colspan="6">

    <div id="div1" style="overflow:auto;height:150px;">
    <asp:GridView ID="ddsales" runat="server" Width="807px" AutoGenerateColumns="false" onrowdatabound="ddsales_RowDataBound" onselectedindexchanged="ddsales_SelectedIndexChanged" onrowcommand="ddsales_RowCommand" ShowFooter="True" onrowdeleting="ddsales_RowDeleting" onselectedindexchanging="ddsales_SelectedIndexChanging" onprerender="ddsales_PreRender" onrowcreated="ddsales_RowCreated">
    <Columns>
    <%--<asp:BoundField DataField="RowNumber" HeaderText="Row Number" /> --%>
    <asp:TemplateField ControlStyle-Width="20px">
    <ItemTemplate>
    <asp:CheckBox ID="chkSelect" runat="server" AutoPostBack="True" oncheckedchanged="chkSelect_CheckedChanged" >
    </asp:CheckBox>
    </ItemTemplate> <ItemStyle Width="20px" />
    <ControlStyle Width="20px" />
    </asp:TemplateField>

    <asp:TemplateField HeaderText="Sectionname" ControlStyle-Width="120px"><ItemTemplate><asp:Label ID="lblsectn" runat="server" Text="<%#bind('sectionname') %>"></asp:Label> </ItemTemplate><ItemStyle Width="120px" VerticalAlign="Bottom" /><ControlStyle Width="120px" /> </asp:TemplateField>

    <asp:TemplateField HeaderText="Product Name" ControlStyle-Width="120px"><ItemTemplate><asp:Label ID="lblproductname" runat="server" Text="<%#bind('productname') %>"></asp:Label></ItemTemplate><ItemStyle Width="120px" VerticalAlign="Bottom" /><ControlStyle Width="120px" /></asp:TemplateField>

    <asp:TemplateField HeaderText="Lotno" ControlStyle-Width="120px"><ItemTemplate><asp:Label ID="lbllotno" runat="server" Text="<%#bind('lotno') %>"></asp:Label></ItemTemplate><ItemStyle Width="120px" VerticalAlign="Bottom" /><ControlStyle Width="120px" /></asp:TemplateField>

    <asp:TemplateField HeaderText="MRP" ControlStyle-Width="120px"><ItemTemplate><asp:Label ID="lblmrp" runat="server" Text="<%#bind('mrp') %>"></asp:Label></ItemTemplate>

    <FooterTemplate><asp:Label ID="Salary" runat="server" /></FooterTemplate>
    <ItemStyle Width="120px" VerticalAlign="Bottom" /><ControlStyle Width="120px" /></asp:TemplateField>
    <asp:TemplateField HeaderText="SupplierName" ControlStyle-Width="120px"><ItemTemplate><asp:Label ID="lblsupliername" runat="server" Text="<%#bind('supplierename') %>"></asp:Label></ItemTemplate><ItemStyle Width="120px" VerticalAlign="Bottom" /><ControlStyle Width="120px" /></asp:TemplateField>
    <asp:TemplateField HeaderText="Sizee" ControlStyle-Width="120px"><ItemTemplate><asp:Label ID="lblsizee" runat="server" Text="<%#bind('sizee') %>"></asp:Label></ItemTemplate><ItemStyle Width="120px" VerticalAlign="Bottom" /><ControlStyle Width="120px" /></asp:TemplateField>
    <asp:TemplateField HeaderText="Delete User Details">
    <ItemTemplate>
    <asp:LinkButton ID="lbRemove" runat="server" CommandArgument='<%#bind("lotno") %>' CommandName="Delete" Text="Remove" ></asp:LinkButton></ItemTemplate>
    <ItemStyle Width="160px" VerticalAlign="Bottom" /><ControlStyle Width="160px" />
    </asp:TemplateField>
    </Columns>
    </asp:GridView>
    </div>

    </td></tr>


    Name : Dotnet Developer-2015
    Email Id :kumaraspcode2009@gmail.com

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.

  • #762278
    Hi

    I have attached Image given below

    Name : Dotnet Developer-2015
    Email Id :kumaraspcode2009@gmail.com

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.

    Delete Attachment


Sign In to post your comments