<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Data Presentation Controls</title><link>http://forums.asp.net/24.aspx</link><description>ASP.NET data-bound controls such as the DataGrid, DataList, GridView, FormView, DetailsView, and Repeater Controls.  &lt;a href="http://aspadvice.com/SignUp/list.aspx?l=23&amp;c=17" target="_blank"&gt;Email List&lt;/a&gt;</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Re: Set the GridView AutoFormat programmatically</title><link>http://forums.asp.net/thread/1989223.aspx</link><pubDate>Mon, 05 Nov 2007 02:07:07 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1989223</guid><dc:creator>netplan</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1989223.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=24&amp;PostID=1989223</wfw:commentRss><description>&lt;p&gt;Hi InsanePaul,&lt;/p&gt;
&lt;p&gt;Here&amp;#39; what I&amp;#39;ve got. I&amp;#39;m still working on it to make it more dynamic but you&amp;#39;ll get the idea on how to create it through code. I&amp;#39;ve created a Game object that retrieves the data I want.&amp;nbsp; 
&lt;p&gt;I&amp;#39;m using BoundFields here instead of AutoGenerateColumns. If you use AutoGenerateColumns then you don&amp;#39;t need to create all these BoundFields. 
&lt;p&gt;I&amp;#39;ve also added a Panel on my ASP page called pnlGames and you&amp;#39;ll see at the end of this routine where I add my GridView to the panel. 
&lt;p&gt;Hope this helps.&lt;pre class="coloredcode"&gt;Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    Dim mygame As New Game   

    Dim grv1 As New GridView

    grv1.AutoGenerateColumns = False
    grv1.CssClass = &amp;quot;contentTable&amp;quot;
    grv1.GridLines = GridLines.Both


    Dim bfldGameDate As New BoundField
    With bfldGameDate
      .HeaderText = &amp;quot;Game Date&amp;quot;
      .DataField = &amp;quot;game_date&amp;quot;
      .DataFormatString = &amp;quot;{0:MM/dd/yy}&amp;quot;
      .HtmlEncode = False
    End With
    grv1.Columns.Add(bfldGameDate)

    Dim bfldGameTime As New BoundField
    With bfldGameTime
      .HeaderText = &amp;quot;Game Time&amp;quot;
      .DataField = &amp;quot;game_time&amp;quot;
      .DataFormatString = &amp;quot;{0:hh:mm tt}&amp;quot;
      .HtmlEncode = False
    End With
    grv1.Columns.Add(bfldGameTime)

    Dim bfldHome As New BoundField
    With bfldHome
      .HeaderText = &amp;quot;Home&amp;quot;
      .DataField = &amp;quot;home_team&amp;quot;
    End With
    grv1.Columns.Add(bfldHome)

    Dim bfldAway As New BoundField
    With bfldAway
      .HeaderText = &amp;quot;Away&amp;quot;
      .DataField = &amp;quot;away_team&amp;quot;
    End With
    grv1.Columns.Add(bfldAway)

    With grv1
      .DataSource = mygame.GetGamesByDate(&amp;quot;21/09/2007 12:00:00 AM&amp;quot;)
      .DataBind()
    End With

    pnlGames.Controls.Add(grv1)


    End Sub&lt;/pre&gt;&amp;nbsp;</description></item><item><title>Re: Set the GridView AutoFormat programmatically</title><link>http://forums.asp.net/thread/1988972.aspx</link><pubDate>Sun, 04 Nov 2007 17:52:03 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1988972</guid><dc:creator>InsanePaul</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1988972.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=24&amp;PostID=1988972</wfw:commentRss><description>&lt;p&gt;hi, i&amp;#39;m stuck trying to create a gridview programmatically. Can you help please?&lt;/p&gt;</description></item><item><title>Re: Set the GridView AutoFormat programmatically</title><link>http://forums.asp.net/thread/1988967.aspx</link><pubDate>Sun, 04 Nov 2007 17:44:49 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1988967</guid><dc:creator>netplan</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1988967.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=24&amp;PostID=1988967</wfw:commentRss><description>&lt;p&gt;Ahhh so that&amp;#39;s the secret. &lt;/p&gt;
&lt;p&gt;Thanks ubaid1900.&lt;/p&gt;</description></item><item><title>Re: Set the GridView AutoFormat programmatically</title><link>http://forums.asp.net/thread/1987686.aspx</link><pubDate>Fri, 02 Nov 2007 20:30:45 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1987686</guid><dc:creator>ubaid1900</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1987686.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=24&amp;PostID=1987686</wfw:commentRss><description>&lt;p&gt;&lt;b&gt;when you apply the &amp;quot;Professional&amp;quot; format in the designer, the plain grid view converts as below. Copy this and paste it into a skin file. Remove the ID=&amp;quot;GridView1&amp;quot; This formatting gets applied to all GridViews.&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&amp;lt;asp:GridView ID=&amp;quot;GridView1&amp;quot; runat=&amp;quot;server&amp;quot; CellPadding=&amp;quot;4&amp;quot; ForeColor=&amp;quot;#333333&amp;quot; GridLines=&amp;quot;None&amp;quot;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;FooterStyle BackColor=&amp;quot;#5D7B9D&amp;quot; Font-Bold=&amp;quot;True&amp;quot; ForeColor=&amp;quot;White&amp;quot; /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;RowStyle BackColor=&amp;quot;#F7F6F3&amp;quot; ForeColor=&amp;quot;#333333&amp;quot; /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;EditRowStyle BackColor=&amp;quot;#999999&amp;quot; /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;SelectedRowStyle BackColor=&amp;quot;#E2DED6&amp;quot; Font-Bold=&amp;quot;True&amp;quot; ForeColor=&amp;quot;#333333&amp;quot; /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;PagerStyle BackColor=&amp;quot;#284775&amp;quot; ForeColor=&amp;quot;White&amp;quot; HorizontalAlign=&amp;quot;Center&amp;quot; /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;HeaderStyle BackColor=&amp;quot;#5D7B9D&amp;quot; Font-Bold=&amp;quot;True&amp;quot; ForeColor=&amp;quot;White&amp;quot; /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;AlternatingRowStyle BackColor=&amp;quot;White&amp;quot; ForeColor=&amp;quot;#284775&amp;quot; /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/asp:GridView&amp;gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&amp;nbsp;If you do not want it across all GridViews, the add SkinId=&amp;quot;ProfessionalSkin&amp;quot; attribute, the set the GridView&amp;#39;s SkinId property to &amp;quot;ProfessionalSkin&amp;quot;&lt;/b&gt;&lt;br /&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;lt;asp:GridView ID=&amp;quot;GridView1&amp;quot; runat=&amp;quot;server&amp;quot; CellPadding=&amp;quot;4&amp;quot; ForeColor=&amp;quot;#333333&amp;quot; GridLines=&amp;quot;None&amp;quot; SkidId=&amp;quot;ProfessionalSkin&amp;quot;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;FooterStyle BackColor=&amp;quot;#5D7B9D&amp;quot; Font-Bold=&amp;quot;True&amp;quot; ForeColor=&amp;quot;White&amp;quot; /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;RowStyle BackColor=&amp;quot;#F7F6F3&amp;quot; ForeColor=&amp;quot;#333333&amp;quot; /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;EditRowStyle BackColor=&amp;quot;#999999&amp;quot; /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;SelectedRowStyle BackColor=&amp;quot;#E2DED6&amp;quot; Font-Bold=&amp;quot;True&amp;quot; ForeColor=&amp;quot;#333333&amp;quot; /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;PagerStyle BackColor=&amp;quot;#284775&amp;quot; ForeColor=&amp;quot;White&amp;quot; HorizontalAlign=&amp;quot;Center&amp;quot; /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;HeaderStyle BackColor=&amp;quot;#5D7B9D&amp;quot; Font-Bold=&amp;quot;True&amp;quot; ForeColor=&amp;quot;White&amp;quot; /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;AlternatingRowStyle BackColor=&amp;quot;White&amp;quot; ForeColor=&amp;quot;#284775&amp;quot; /&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/asp:GridView&amp;gt; &lt;br /&gt;&lt;/p&gt;</description></item><item><title>Set the GridView AutoFormat programmatically</title><link>http://forums.asp.net/thread/1987470.aspx</link><pubDate>Fri, 02 Nov 2007 17:58:43 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1987470</guid><dc:creator>netplan</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1987470.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=24&amp;PostID=1987470</wfw:commentRss><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I&amp;#39;m displaying a GridView programmatically in my code and I was wondering if there was a way to set the AutoFormat programmatically to use &amp;quot;Professional&amp;quot;?&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;</description></item></channel></rss>