-->
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ShowFontsEx01.aspx.cs" Inherits="LearnAsp.Net.ControlDemo.DataBound.ShowFontsEx01" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Show Fonts</title> </head> <body> <form id="form1" runat="server"> <div> <asp:GridView ID="GridView1" ForeColor="#246cb3" BackColor="#e6e6e6" BorderColor="#928383" runat="server" /> </div> </form> </body> </html>
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Drawing.Text; namespace LearnAsp.Net.ControlDemo.DataBound { public partial class ShowFontsEx01 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { InstalledFontCollection fonts = new InstalledFontCollection(); GridView1.DataSource = fonts.Families; GridView1.DataBind(); } } } }
Thanks for reading Asp.Net Programmatic DataBinding