Asp.net - How to introduce scrolling in gridview control - asp.net

I am using Vb.net for coding. I have a grid view control in which i want to introduce a vertical scroll bar if the value from the sql query overflows. How do I go about it?

You could place the gridview in a div with the following style:
overflow: auto; height: 80px;.

The following markup should do this. You'll need to change the height as required.
<div style="overflow-y:auto; height:200px">
<asp:GridView ID="GridView1" runat="server" >
</asp:GridView>
</div>

Related

How to put an Vertical scrollbar within asp:Repeater ItemTemplate?

I have inherited an .ascx control that consists of an asp:repeater construct containing a HeaderTemplate, an ItemTemplate and an empty FooterTemplate.
Both the header and the item templates are linked to a data source.
My question is simply this, I want to have a vertical slider applied to the ItemTemplate such that I can scroll up and down the items contained within whilst the HeaderTemplate remains static.
I have tried using an asp:Panel within the ItemTemplate but this doesn't render the row within the template.
I've resorted to encapsulating the whole of the asp:Repeater within an asp:Panel that specifies a vertical scrollbar. This works but scrolls the header out of view if the number of rows in the ItemTemplate is large.
If anyone can help and suggest a way forward I would be most grateful.
It can be done in a simple manner with some CSS tricks e.g.
Repeater Item Template Markup
<HeaderTemplate>
<div class="template">
</HeaderTemplate>
<ItemTemplate>
Your Stuff
</ItemTemplate>
<FooterTemplate>
</div>
</FooterTemplate>
CSS Defined for "template"
.template {
height: 200px;
overflow-y: scroll;
}
Hope this will help !!

Changing a div to Text Box?

I have a div area like the following in my .aspx program.
<div id="valueIntroduction" type="text" class="labelarea" runat="server">
</div>
<div class="line"></div>
<asp:Button ID="editButton" runat="server" Text="Edit" />
Currently the div valueIntroduction is getting data from database. I have a Edit button in my program. When i press Edit button I am trying to change the div to text box.
Try this..
1.Add a textbox and make visible="false"
2.when clicking edit button copy the div's contents to the textbox and make div invisible by using visibility:"hidden".
3.Set the textbox visibility to true.
Try putting an invisible textbox below your div, then when you click the edit button, transfer the contents of the div into the textbox, make the textbox visible and the div invisible.

Div produced from an ASP.Net GridView is too large

I have an ASP.Net GridView with properties like so:
<asp:GridView ID="grdOrderEntry" runat="server" AutoGenerateColumns="false" ShowFooter="True"
DataKeyNames="oid" Height="100%">
When I view the control in the browser, there is a lot of white space after the control. When viewing the HTML, the div that is produced by the GridView is much larger than the control, causing the whitespace. Is there a property I can set on the GridView to make the div as small as possible?
If you set the CssClass property you will be able to create some css to address the problem. I would recommend using a live css editor so you can mess around with it until you get the desired effect.
I suspect this is being caused by your Height="100%" attribute, remove that, and it should just stretch around the table it contains (unless there is some css other style added to it as well).

ASP.NET A problem with Panel Direction property

I add a user control dynamically (which only contains a table) to the Panel:
<asp:Panel ID="panel" runat="server"
ScrollBars="Horizontal" Width="160" Direction="LeftToRight">
</asp:Panel>
when I add e.g. two user controls, they have vertical direction. Why ? I want them set from left to right (horizontally)
The Direction property only sets whether the text is displayed left-to-right or right-to-left. It's a usability feature.
What you'll want to do is use CSS to perform what you need. Look into float: right;

How to disable the gridview rows border

Can we disable the gridview horizontal line ? I want to display grid without horizontal lines
help me thank you.
Set GridLines="None" on your GridView
Setting both:
BorderStyle="None"
and
GridLines="None"
on your Gridview will remove all of the lines.
use this code for your GridView to disable lines
GridView1.GridLines = GridLines.None;
The GridView renders as a table so wrap your GridView in a <div> with a class that sets the border of all contained <td> to 0
Kindness,
Dan
Try using this:
BorderWidth="0px"

Resources