Gridview Checkbox Alignment Problem

Discussion in 'ASP .Net' started by JonBosker, Jan 24, 2007.

  1. JonBosker

    JonBosker Guest

    I am having a strange problem - my GridView is displaying bits (from
    SQL Server) as checkboxes (which is fine) but it shows each alternating
    one centrally aligned.

    Heading1 Heading2
    Text [X] Checkbox
    Text2 [X] Checkbox
    Text3 [X] Checkbox
    Text4 [X] Checkbox

    My GridView is very generic and I use it to show data from any table.

    I think it is controlled by CSS but which item / setting? Can anyone
    help??

    Here is my gridview defintion (I set the Select and Delete command at
    runtime):

    <asp:GridView ID="GridView1" runat="server"
    DataSourceID="SqlDataSource1" AllowPaging="True"
    OnSelectedIndexChanged="GridView1_SelectedIndexChanged"
    CssClass="GridStyle"
    AllowSorting="True" OnRowDeleting="GridView1_RowDeleting"
    Width="100%">
    <RowStyle CssClass="RowStyle" HorizontalAlign="Left" />
    <AlternatingRowStyle CssClass="AlternatingRowStyle"
    HorizontalAlign="Left" />
    <PagerSettings FirstPageImageUrl="../systemimages/First.png"
    FirstPageText="" LastPageImageUrl="~/systemimages/Last.png"
    LastPageText="" Mode="NextPreviousFirstLast"
    NextPageImageUrl="~/systemimages/Next.png"
    NextPageText=""
    PreviousPageImageUrl="../systemimages/Prev.png" PreviousPageText="" />
    <PagerStyle CssClass="CommandRowStyle" />
    </asp:GridView>

    <asp:SqlDataSource ID="SqlDataSource1" runat="server"
    ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
    SelectCommand="SELECT * FROM [Table]" DeleteCommand="DELETE
    FROM [Table] WHERE SOmeId=@original_SomeId"
    OnDeleted="SqlDataSource1_Deleted"></asp:SqlDataSource>
     
    JonBosker, Jan 24, 2007
    #1
    1. Advertising

  2. Check AlternatingRowStyle.

    --
    Eliyahu Goldin,
    Software Developer & Consultant
    Microsoft MVP [ASP.NET]
    http://msmvps.com/blogs/egoldin


    "JonBosker" <> wrote in message
    news:...
    > I am having a strange problem - my GridView is displaying bits (from
    > SQL Server) as checkboxes (which is fine) but it shows each alternating
    > one centrally aligned.
    >
    > Heading1 Heading2
    > Text [X] Checkbox
    > Text2 [X] Checkbox
    > Text3 [X] Checkbox
    > Text4 [X] Checkbox
    >
    > My GridView is very generic and I use it to show data from any table.
    >
    > I think it is controlled by CSS but which item / setting? Can anyone
    > help??
    >
    > Here is my gridview defintion (I set the Select and Delete command at
    > runtime):
    >
    > <asp:GridView ID="GridView1" runat="server"
    > DataSourceID="SqlDataSource1" AllowPaging="True"
    > OnSelectedIndexChanged="GridView1_SelectedIndexChanged"
    > CssClass="GridStyle"
    > AllowSorting="True" OnRowDeleting="GridView1_RowDeleting"
    > Width="100%">
    > <RowStyle CssClass="RowStyle" HorizontalAlign="Left" />
    > <AlternatingRowStyle CssClass="AlternatingRowStyle"
    > HorizontalAlign="Left" />
    > <PagerSettings FirstPageImageUrl="../systemimages/First.png"
    > FirstPageText="" LastPageImageUrl="~/systemimages/Last.png"
    > LastPageText="" Mode="NextPreviousFirstLast"
    > NextPageImageUrl="~/systemimages/Next.png"
    > NextPageText=""
    > PreviousPageImageUrl="../systemimages/Prev.png" PreviousPageText="" />
    > <PagerStyle CssClass="CommandRowStyle" />
    > </asp:GridView>
    >
    > <asp:SqlDataSource ID="SqlDataSource1" runat="server"
    > ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
    > SelectCommand="SELECT * FROM [Table]" DeleteCommand="DELETE
    > FROM [Table] WHERE SOmeId=@original_SomeId"
    > OnDeleted="SqlDataSource1_Deleted"></asp:SqlDataSource>
    >
     
    Eliyahu Goldin, Jan 24, 2007
    #2
    1. Advertising

  3. JonBosker

    JonBosker Guest

    On Jan 24, 6:31 pm, "Eliyahu Goldin"
    <> wrote:
    > Check AlternatingRowStyle.
    >

    Turns out it was not AlternatingRowStyle but RowStyle instead - and
    more specifically I had an input sub-type (is that the word?) as shown
    below:
    ..RowStyle
    {
    color:Navy;
    font-variant:normal;
    text-align:left;
    }

    ..RowStyle input
    {
    width:90%;
    }

    I think that because it is set to 90% the control (checkbox) tries to
    fill 90% of the box but as it cannot stretch ends up putting it in the
    middle! Pretty bizarre! Thanks.
     
    JonBosker, Feb 1, 2007
    #3
    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. Replies:
    0
    Views:
    329
  2. tshad

    Checkbox text alignment

    tshad, Mar 7, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    566
    tshad
    Mar 7, 2005
  3. Benton

    GridView and Column alignment

    Benton, Aug 23, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    17,038
    Siva M
    Aug 23, 2005
  4. =?Utf-8?B?QmFobWFu?=

    Checkbox Text Alignment

    =?Utf-8?B?QmFobWFu?=, Feb 8, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    2,635
    =?Utf-8?B?QmFobWFu?=
    Feb 9, 2006
  5. Prince
    Replies:
    1
    Views:
    6,221
    Adrienne Boswell
    Feb 22, 2008
Loading...

Share This Page