<%@ Page Language="C#" AutoEventWireup="true" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Button1_Click(object sender, System.EventArgs e)
{
GridView1.SelectedRowStyle.VerticalAlign = VerticalAlign.Bottom;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>How to set change GridView selected 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 Selected 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"
Width="525"
BackColor="OrangeRed"
ForeColor="Snow"
BorderColor="Orange"
Font-Names="Comic Sans MS"
AutoGenerateColumns="false"
AutoGenerateSelectButton="true"
>
<PagerStyle
ForeColor="Tan"
Height="40"
BackColor="IndianRed"
Font-Size="Large"
VerticalAlign="Top"
HorizontalAlign="Left"
/>
<SelectedRowStyle
BackColor="Salmon"
BorderColor="Orange"
Height="40"
/>
<HeaderStyle
BackColor="RosyBrown"
BorderColor="Tan"
Height="35"
Font-Italic="false"
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 Selected Row Vertical Align Bottom"
Font-Bold="true"
Height="45"
ForeColor="OrangeRed"
OnClick="Button1_Click"
/>
</div>
</form>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Button1_Click(object sender, System.EventArgs e)
{
GridView1.SelectedRowStyle.VerticalAlign = VerticalAlign.Bottom;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>How to set change GridView selected 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 Selected 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"
Width="525"
BackColor="OrangeRed"
ForeColor="Snow"
BorderColor="Orange"
Font-Names="Comic Sans MS"
AutoGenerateColumns="false"
AutoGenerateSelectButton="true"
>
<PagerStyle
ForeColor="Tan"
Height="40"
BackColor="IndianRed"
Font-Size="Large"
VerticalAlign="Top"
HorizontalAlign="Left"
/>
<SelectedRowStyle
BackColor="Salmon"
BorderColor="Orange"
Height="40"
/>
<HeaderStyle
BackColor="RosyBrown"
BorderColor="Tan"
Height="35"
Font-Italic="false"
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 Selected Row Vertical Align Bottom"
Font-Bold="true"
Height="45"
ForeColor="OrangeRed"
OnClick="Button1_Click"
/>
</div>
</form>
</body>
</html>
No comments:
Post a Comment