locked
Format GridView Columns RRS feed

  • Question

  • User-395883933 posted

    Please help!

    I have a Dictionary of Appointments <int, Appointment> loaded with appointment objects. I am supposed to display all appointments in a GridView. I got that already going but I dont know how to change the names of the columns, center the text on specific columns and any other formatting. 

    ASP 

    <asp:GridView ID="GridView1" runat="server" Width="467px">
    </asp:GridView>       
    
    
    C#
    Appointments apts = new Appointments(); //I initialized the dictionary "dict" inside appointments class in the constructor
    GridView1.DataSource = apts.dict.Values;
    GridView1.DataBind();
    Wednesday, September 28, 2011 2:17 PM

Answers

  • User-608283337 posted

     

    <asp:GridView ID="GridView1" runat="server" Width="467px" AutoGenerateColumns="False">

          <Columns>

            <asp:BoundField DataField="YourBindFIeldNameInDatabase" HeaderText="YourColumnName" ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="9%">    

         </asp:BoundField>

          </Columns>

    </asp:GridView>  
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, September 28, 2011 2:29 PM

All replies

  • User-608283337 posted

     

    <asp:GridView ID="GridView1" runat="server" Width="467px" AutoGenerateColumns="False">

          <Columns>

            <asp:BoundField DataField="YourBindFIeldNameInDatabase" HeaderText="YourColumnName" ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="9%">    

         </asp:BoundField>

          </Columns>

    </asp:GridView>  
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, September 28, 2011 2:29 PM
  • User-395883933 posted

    That did it! Thanks!!!

    Wednesday, September 28, 2011 2:34 PM