Introduction:
In this article demonstrates,how to create a scrollable gridview in asp.net 2.0.
Main:
We can easily create a scrollable gridview using gridview RowStyle-***Align gridview property,
See this simple examble,
Html Code for creating scrollable gridview,
<div>
<asp:Panel ID="Scroll" runat="server" Height="400px"
Width="350px" ScrollBars="Vertical">
<asp:GridView ID="ScrollView" runat="server"
AutoGenerateColumns="False"
DataSourceID="SqlSource"
RowStyle-VerticalAlign="Bottom">
</asp:GridView>
<asp:SqlDataSource ID="SqlSource" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [Emp_Id], [Emp_Name], FROM [ EMP]">
</asp:SqlDataSource>
</asp:Panel>
</div>
<div> <asp:Panel ID="Scroll" runat="server" Height="400px" Width="350px" ScrollBars="Vertical"> <asp:GridView ID="ScrollView" runat="server" AutoGenerateColumns="False" DataSourceID="SqlSource" RowStyle-VerticalAlign="Bottom"> </asp:GridView> <asp:SqlDataSource ID="SqlSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT [Emp_Id], [Emp_Name], FROM [ EMP]"> </asp:SqlDataSource> </asp:Panel> </div> |
Conclusion:
Hope this helps,
Happy Coding.