Easy Datagrid question

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default Easy Datagrid question

    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 Guest

  2. Similar Questions and Discussions

    1. I have an easy question.
      I want to create plan - add a texture to it - create a second plan then add that same original texture to the second plane. When I attempt to add...
    2. Easy way to clear the DataGrid
      Is there a function to clear the Items out of the DataGrid or DataList? In my page I want the user to be able to do different searches and before...
    3. DataGrid easy Edit-Update using ADO.NET/DataGrid functionality C#?
      Hi, so I am using built in Edit, Delete, Update i.e. OnEditCommand="DataGrid1_Edit" OnUpdateCommand="DataGrid1_Update" with handler question below...
    4. Easy question = easy answer?
      Well, so I'm pretty new with Freehand, at the mo running with MX and havin' a problem (not big, but anyway)... I'm creating some cards and they...
    5. Easy Question/Easy Answer
      Ok, this is all i want to know how to do, i made a text link, now when someone rolls over it with their pointer i want it to change color. Simple?
  3. #2

    Default Re: Easy Datagrid question

    Are you setting it before or after the databind?


    --
    S. Justin Gengo, MCP
    Web Developer

    Free code library at:
    [url]www.aboutfortunate.com[/url]

    "Out of chaos comes order."
    Nietzche
    "AC" <acentrella@cantor.com> wrote in message
    news:0cf201c34d39$f3cbf310$a501280a@phx.gbl...
    > 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 Guest

  4. #3

    Default Re: Easy Datagrid question

    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:
    [url]www.aboutfortunate.com[/url]

    "Out of chaos comes order."
    Nietzche
    "AC" <acentrella@cantor.com> wrote in message
    news:0e9101c34d3c$1047bfe0$a401280a@phx.gbl...
    > 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:
    > >[url]www.aboutfortunate.com[/url]
    > >
    > >"Out of chaos comes order."
    > > Nietzche
    > >"AC" <acentrella@cantor.com> wrote in message
    > >news:0cf201c34d39$f3cbf310$a501280a@phx.gbl...
    > >> 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 Guest

  5. #4

    Default Re: Easy Datagrid question

    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:
    >[url]www.aboutfortunate.com[/url]
    >
    >"Out of chaos comes order."
    > Nietzche
    >"AC" <acentrella@cantor.com> wrote in message
    >news:0e9101c34d3c$1047bfe0$a401280a@phx.gbl...
    >> 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:
    >> >[url]www.aboutfortunate.com[/url]
    >> >
    >> >"Out of chaos comes order."
    >> > Nietzche
    >> >"AC" <acentrella@cantor.com> wrote in message
    >> >news:0cf201c34d39$f3cbf310$a501280a@phx.gbl...
    >> >> 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 Guest

  6. #5

    Default Re: Easy Datagrid question

    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:
    [url]www.aboutfortunate.com[/url]

    "Out of chaos comes order."
    Nietzche
    "AC" <acentrella@cantor.com> wrote in message
    news:0e0c01c34d46$0f894650$a501280a@phx.gbl...
    > 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:
    > >[url]www.aboutfortunate.com[/url]
    > >
    > >"Out of chaos comes order."
    > > Nietzche
    > >"AC" <acentrella@cantor.com> wrote in message
    > >news:0e9101c34d3c$1047bfe0$a401280a@phx.gbl...
    > >> 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:
    > >> >[url]www.aboutfortunate.com[/url]
    > >> >
    > >> >"Out of chaos comes order."
    > >> > Nietzche
    > >> >"AC" <acentrella@cantor.com> wrote in message
    > >> >news:0cf201c34d39$f3cbf310$a501280a@phx.gbl...
    > >> >> 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 Guest

  7. #6

    Default Re: Easy Datagrid question

    Hello,

    Please refer to [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-[/url]
    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! - [url]www.microsoft.com/security[/url]
    This posting is provided "AS IS" with no warranties, and confers no rights.

    --------------------
    !Content-Class: urn:content-classes:message
    !From: "AC" <acentrella@cantor.com>
    !Sender: "AC" <acentrella@cantor.com>
    !References: <0cf201c34d39$f3cbf310$a501280a@phx.gbl> <uH6tqpTTDHA.1912@tk2msftngp13.phx.gbl> <0e9101c34d3c
    $1047bfe0$a401280a@phx.gbl> <uokKHCUTDHA.1916@TK2MSFTNGP12.phx.gbl>
    !Subject: Re: Easy Datagrid question
    !Date: Fri, 18 Jul 2003 09:03:00 -0700
    !Lines: 57
    !Message-ID: <0e0c01c34d46$0f894650$a501280a@phx.gbl>
    !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:
    !>[url]www.aboutfortunate.com[/url]
    !>
    !>"Out of chaos comes order."
    !> Nietzche
    !>"AC" <acentrella@cantor.com> wrote in message
    !>news:0e9101c34d3c$1047bfe0$a401280a@phx.gbl...
    !>> 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:
    !>> >[url]www.aboutfortunate.com[/url]
    !>> >
    !>> >"Out of chaos comes order."
    !>> > Nietzche
    !>> >"AC" <acentrella@cantor.com> wrote in message
    !>> >news:0cf201c34d39$f3cbf310$a501280a@phx.gbl...
    !>> >> 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] Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139