Easy Datagrid question

Discussion in 'ASP .Net' started by AC, Jul 18, 2003.

  1. AC

    AC Guest

    Any reason i'm having trouble with:

    DataGrid1.Columns(7).ItemStyle.HorizontalAlign =
    HorizontalAlign.Right

    I'm trying to directly set the column alignment of a
    datagrid created at runtime..

    AC
    AC, Jul 18, 2003
    #1
    1. Advertising

  2. Are you setting it before or after the databind?


    --
    S. Justin Gengo, MCP
    Web Developer

    Free code library at:
    www.aboutfortunate.com

    "Out of chaos comes order."
    Nietzche
    "AC" <> wrote in message
    news:0cf201c34d39$f3cbf310$...
    > Any reason i'm having trouble with:
    >
    > DataGrid1.Columns(7).ItemStyle.HorizontalAlign =
    > HorizontalAlign.Right
    >
    > I'm trying to directly set the column alignment of a
    > datagrid created at runtime..
    >
    > AC
    S. Justin Gengo, Jul 18, 2003
    #2
    1. Advertising

  3. I think if you set it before it will work. Let me know if it does. I usually
    set the item alignment in the html, but I've noticed other properties
    behaving differently at runtime depending on whether they are set before or
    after a databind so I think this might be one of them.

    --
    S. Justin Gengo, MCP
    Web Developer

    Free code library at:
    www.aboutfortunate.com

    "Out of chaos comes order."
    Nietzche
    "AC" <> wrote in message
    news:0e9101c34d3c$1047bfe0$...
    > After - should it be before?
    >
    > >-----Original Message-----
    > >Are you setting it before or after the databind?
    > >
    > >
    > >--
    > >S. Justin Gengo, MCP
    > >Web Developer
    > >
    > >Free code library at:
    > >www.aboutfortunate.com
    > >
    > >"Out of chaos comes order."
    > > Nietzche
    > >"AC" <> wrote in message
    > >news:0cf201c34d39$f3cbf310$...
    > >> Any reason i'm having trouble with:
    > >>
    > >> DataGrid1.Columns(7).ItemStyle.HorizontalAlign =
    > >> HorizontalAlign.Right
    > >>
    > >> I'm trying to directly set the column alignment of a
    > >> datagrid created at runtime..
    > >>
    > >> AC

    > >
    > >
    > >.
    > >
    S. Justin Gengo, Jul 18, 2003
    #3
  4. AC

    AC Guest

    That doesn't work... question: how do you set in html if
    you add the columns at runtime?

    >-----Original Message-----
    >I think if you set it before it will work. Let me know if

    it does. I usually
    >set the item alignment in the html, but I've noticed

    other properties
    >behaving differently at runtime depending on whether they

    are set before or
    >after a databind so I think this might be one of them.
    >
    >--
    >S. Justin Gengo, MCP
    >Web Developer
    >
    >Free code library at:
    >www.aboutfortunate.com
    >
    >"Out of chaos comes order."
    > Nietzche
    >"AC" <> wrote in message
    >news:0e9101c34d3c$1047bfe0$...
    >> After - should it be before?
    >>
    >> >-----Original Message-----
    >> >Are you setting it before or after the databind?
    >> >
    >> >
    >> >--
    >> >S. Justin Gengo, MCP
    >> >Web Developer
    >> >
    >> >Free code library at:
    >> >www.aboutfortunate.com
    >> >
    >> >"Out of chaos comes order."
    >> > Nietzche
    >> >"AC" <> wrote in message
    >> >news:0cf201c34d39$f3cbf310$...
    >> >> Any reason i'm having trouble with:
    >> >>
    >> >> DataGrid1.Columns(7).ItemStyle.HorizontalAlign =
    >> >> HorizontalAlign.Right
    >> >>
    >> >> I'm trying to directly set the column alignment of a
    >> >> datagrid created at runtime..
    >> >>
    >> >> AC
    >> >
    >> >
    >> >.
    >> >

    >
    >
    >.
    >
    AC, Jul 18, 2003
    #4
  5. I don't add the columns at runtime. I add them in the html also.

    <asp:datagrid id="DataGrid1" runat="server" autogeneratecolumns="False">
    <itemstyle HorizontalAlign="Left" VerticalAlign="Top" forecolor="Black"
    backcolor="White"></itemstyle>
    <columns>
    <asp:boundcolumn datafield="LastName" headertext="Last Name">
    </columns>
    </asp:datagrid>

    Then I just databind. As long as the columns datafield matches a column in
    the datatable or dataview bound to the grid it self fills.
    --
    S. Justin Gengo, MCP
    Web Developer

    Free code library at:
    www.aboutfortunate.com

    "Out of chaos comes order."
    Nietzche
    "AC" <> wrote in message
    news:0e0c01c34d46$0f894650$...
    > That doesn't work... question: how do you set in html if
    > you add the columns at runtime?
    >
    > >-----Original Message-----
    > >I think if you set it before it will work. Let me know if

    > it does. I usually
    > >set the item alignment in the html, but I've noticed

    > other properties
    > >behaving differently at runtime depending on whether they

    > are set before or
    > >after a databind so I think this might be one of them.
    > >
    > >--
    > >S. Justin Gengo, MCP
    > >Web Developer
    > >
    > >Free code library at:
    > >www.aboutfortunate.com
    > >
    > >"Out of chaos comes order."
    > > Nietzche
    > >"AC" <> wrote in message
    > >news:0e9101c34d3c$1047bfe0$...
    > >> After - should it be before?
    > >>
    > >> >-----Original Message-----
    > >> >Are you setting it before or after the databind?
    > >> >
    > >> >
    > >> >--
    > >> >S. Justin Gengo, MCP
    > >> >Web Developer
    > >> >
    > >> >Free code library at:
    > >> >www.aboutfortunate.com
    > >> >
    > >> >"Out of chaos comes order."
    > >> > Nietzche
    > >> >"AC" <> wrote in message
    > >> >news:0cf201c34d39$f3cbf310$...
    > >> >> Any reason i'm having trouble with:
    > >> >>
    > >> >> DataGrid1.Columns(7).ItemStyle.HorizontalAlign =
    > >> >> HorizontalAlign.Right
    > >> >>
    > >> >> I'm trying to directly set the column alignment of a
    > >> >> datagrid created at runtime..
    > >> >>
    > >> >> AC
    > >> >
    > >> >
    > >> >.
    > >> >

    > >
    > >
    > >.
    > >
    S. Justin Gengo, Jul 18, 2003
    #5
  6. Hello,

    Please refer to http://msdn.microsoft.com/library/default.asp?url=/library/en-
    us/dv_vstechart/html/vbtchtopquestionsaboutaspnetdatagridservercontrol.asp for how to set column alignment in datagrid.

    The content of this article includes:

    Windows Forms versus Web Forms DataGrid Controls
    Controlling Column Width, Height, and Alignment
    Customizing Column Layout in Display and Edit Mode
    Formatting Dates, Currency, and Other Data
    Showing and Hiding Columns Dynamically
    Adding Columns Dynamically
    Adding New Records to a Data Source Using the DataGrid Control
    Displaying a Drop-Down List in Edit Mode
    Selecting Multiple Items Using a Check Box (Hotmail Model)
    Editing Multiple Rows At Once
    Selecting Rows by Clicking Anywhere

    Hope it helps.

    Best regards,
    Yanhong Huang
    Microsoft Online Partner Support

    Get Secure! - www.microsoft.com/security
    This posting is provided "AS IS" with no warranties, and confers no rights.

    --------------------
    !Content-Class: urn:content-classes:message
    !From: "AC" <>
    !Sender: "AC" <>
    !References: <0cf201c34d39$f3cbf310$> <> <0e9101c34d3c
    $1047bfe0$> <>
    !Subject: Re: Easy Datagrid question
    !Date: Fri, 18 Jul 2003 09:03:00 -0700
    !Lines: 57
    !Message-ID: <0e0c01c34d46$0f894650$>
    !MIME-Version: 1.0
    !Content-Type: text/plain;
    ! charset="iso-8859-1"
    !Content-Transfer-Encoding: 7bit
    !X-Newsreader: Microsoft CDO for Windows 2000
    !Thread-Index: AcNNRg+Jm/ERMH8oTyWbCBOkJgOekw==
    !X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
    !Newsgroups: microsoft.public.dotnet.framework.aspnet
    !Path: cpmsftngxa06.phx.gbl
    !Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:160335
    !NNTP-Posting-Host: TK2MSFTNGXA13 10.40.1.165
    !X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    !
    !That doesn't work... question: how do you set in html if
    !you add the columns at runtime?
    !
    !>-----Original Message-----
    !>I think if you set it before it will work. Let me know if
    !it does. I usually
    !>set the item alignment in the html, but I've noticed
    !other properties
    !>behaving differently at runtime depending on whether they
    !are set before or
    !>after a databind so I think this might be one of them.
    !>
    !>--
    !>S. Justin Gengo, MCP
    !>Web Developer
    !>
    !>Free code library at:
    !>www.aboutfortunate.com
    !>
    !>"Out of chaos comes order."
    !> Nietzche
    !>"AC" <> wrote in message
    !>news:0e9101c34d3c$1047bfe0$...
    !>> After - should it be before?
    !>>
    !>> >-----Original Message-----
    !>> >Are you setting it before or after the databind?
    !>> >
    !>> >
    !>> >--
    !>> >S. Justin Gengo, MCP
    !>> >Web Developer
    !>> >
    !>> >Free code library at:
    !>> >www.aboutfortunate.com
    !>> >
    !>> >"Out of chaos comes order."
    !>> > Nietzche
    !>> >"AC" <> wrote in message
    !>> >news:0cf201c34d39$f3cbf310$...
    !>> >> Any reason i'm having trouble with:
    !>> >>
    !>> >> DataGrid1.Columns(7).ItemStyle.HorizontalAlign =
    !>> >> HorizontalAlign.Right
    !>> >>
    !>> >> I'm trying to directly set the column alignment of a
    !>> >> datagrid created at runtime..
    !>> >>
    !>> >> AC
    !>> >
    !>> >
    !>> >.
    !>> >
    !>
    !>
    !>.
    !>
    !
    Yan-Hong Huang[MSFT], Jul 22, 2003
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hazzard
    Replies:
    2
    Views:
    623
    Hazzard
    Apr 6, 2004
  2. RockNRoll
    Replies:
    1
    Views:
    3,427
    Raterus
    Aug 2, 2004
  3. Roger
    Replies:
    2
    Views:
    388
    =?Utf-8?B?Q293Ym95IChHcmVnb3J5IEEuIEJlYW1lcikgLSBN
    May 20, 2005
  4. Bruno Desthuilliers
    Replies:
    5
    Views:
    370
    Bruno Desthuilliers
    Aug 29, 2007
  5. Kostia
    Replies:
    1
    Views:
    254
    Scott Mitchell [MVP]
    Feb 26, 2004
Loading...

Share This Page