GridView header row vertical align
asp.net gridview display tabular data. so it display data as a table. table includes header, footer,
data row, alternate row and pager. table data are arranged in columns and rows. in gridview header row
columns are display. columns separated by border and columns text are data table columns title.
this example show how can you set change gridview header row text vertical align. header row vertical align exists in gridview header style template section. here you can set the header vertical align value. or you can change the vertical align value top bottom middle programmatically. this tutorial present programmatically changing gridview header text vertical align.
this example show how can you set change gridview header row text vertical align. header row vertical align exists in gridview header style template section. here you can set the header vertical align value. or you can change the vertical align value top bottom middle programmatically. this tutorial present programmatically changing gridview header text vertical align.
GridViewHeaderVerticalAlign.aspx
<%@ Page Language="C#" AutoEventWireup="true" %>
<!DOCTYPE html>
<script runat="server">
protected void Button1_Click(object sender, System.EventArgs e)
{
GridView1.HeaderStyle.VerticalAlign = VerticalAlign.Bottom;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>How to set change GridView header row vertical align programmatically in asp.net</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:Navy; font-style:italic;">GridView Example: Change Header Row Vertical Align</h2>
<asp:SqlDataSource
ID="SqlDataSource2"
runat="server"
ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
SelectCommand="Select ProductID, ProductName, UnitPrice From Products"
CancelSelectOnNullParameter="false"
>
</asp:SqlDataSource>
<asp:GridView
ID="GridView1"
runat="server"
DataSourceID="SqlDataSource2"
AllowPaging="true"
BackColor="OrangeRed"
ForeColor="Snow"
BorderColor="Orange"
Font-Names="Comic Sans MS"
AutoGenerateColumns="false"
Width="500"
>
<PagerStyle
BackColor="IndianRed"
ForeColor="PeachPuff"
Font-Size="Large"
HorizontalAlign="Right"
/>
<HeaderStyle
BackColor="DeepPink"
Font-Italic="false"
Height="50"
ForeColor="Snow"
/>
<Columns>
<asp:BoundField DataField="ProductID" HeaderText="Product ID" ReadOnly="true" />
<asp:BoundField DataField="Productname" HeaderText="Product Name" />
<asp:BoundField DataField="UnitPrice" HeaderText="Unit Price" />
</Columns>
</asp:GridView>
<br />
<asp:Button
ID="Button1"
runat="server"
Text="Set Header Row VerticalAlign Bottom"
Font-Bold="true"
Height="45"
ForeColor="Crimson"
OnClick="Button1_Click"
/>
</div>
</form>
</body>
</html>

