Datagrid: aligning a template column

Ask a Question related to ASP.NET Data Grid Control, Design and Development.

  1. #1

    Default Datagrid: aligning a template column

    Hi,

    Is it possible to align a template column? Tried align, textalign and
    itemstyle (but I think that one is for the whole grid?), and nothing works.
    It's a simple datagrid, but one field is a dollar ($) value, so I've had to
    do a TemplateColumn so that I could make it have the '$'-sign and the
    decimal places, but it's aligned to the left which is kinda ugly. Any ideas
    how to change this column alone or another way to do this?

    Many thanks,
    Naomi


    d[ - - ]b Guest

  2. Similar Questions and Discussions

    1. How to set different label value in datagrid template column?
      Hi all, I have a datagrid with a stock label "lblStock". Here's is what i what to do : 1. If the quantity value retrieved from database is = 0...
    2. Problem with Template Column in Datagrid
      When adding a template column to a datagrid the following error is displayed on page load. The datagrid is bound to a class and the fieldname does...
    3. Bound Column or Template Column (w dAdapater?) in DataGrid
      I am able to get the data using DataAdapter and the DataReader. I am more inclined to use DataAdapter because I want to update the data on the SQL...
    4. Aligning the controls in the item template of the datagrid
      I have got the datagrid control with item template property , and i want to align the textboxes or checkboxes in the header template of the...
    5. DataGrid / Template Column
      I have a DataGrid with a template column (displaying a checkbox). The rows of the datagrid are being populated from a db table. Currently, only one...
  3. #2

    Default Re: Datagrid: aligning a template column

    What i have done is create another table inside the TD


    public void InstantiateIn(System.Web.UI.Control container){
    CheckBox lc = new CheckBox();
    lc.EnableViewState = true;
    lc.DataBinding += new EventHandler(BindCol);
    Literal startLC = new Literal();
    startLC.Text = "<TABLE width=100% border=0 cellspacing=0
    cellpading=0><TR><TD align=center>";
    Literal endLC = new Literal();
    endLC.Text = "</TD></TR></TABLE>";
    container.Controls.Add(startLC);
    container.Controls.Add(lc);
    container.Controls.Add(endLC);
    }

    Hope it Helps!

    "d[ - - ]b" <nospamplz@goaway.xyz> wrote in message news:<c8bsm7$ouv$1@lust.ihug.co.nz>...
    > Hi,
    >
    > Is it possible to align a template column? Tried align, textalign and
    > itemstyle (but I think that one is for the whole grid?), and nothing works.
    > It's a simple datagrid, but one field is a dollar ($) value, so I've had to
    > do a TemplateColumn so that I could make it have the '$'-sign and the
    > decimal places, but it's aligned to the left which is kinda ugly. Any ideas
    > how to change this column alone or another way to do this?
    >
    > Many thanks,
    > Naomi
    Amar Guest

  4. #3

    Default Re: Datagrid: aligning a template column

    Ok, thanks Amar. I'll give it a go!

    "Amar" <amaretos@yahoo.com> wrote in message
    news:7c627043.0405172328.1a1bcb73@posting.google.c om...
    > What i have done is create another table inside the TD
    >
    >
    > public void InstantiateIn(System.Web.UI.Control container){
    > CheckBox lc = new CheckBox();
    > lc.EnableViewState = true;
    > lc.DataBinding += new EventHandler(BindCol);
    > Literal startLC = new Literal();
    > startLC.Text = "<TABLE width=100% border=0 cellspacing=0
    > cellpading=0><TR><TD align=center>";
    > Literal endLC = new Literal();
    > endLC.Text = "</TD></TR></TABLE>";
    > container.Controls.Add(startLC);
    > container.Controls.Add(lc);
    > container.Controls.Add(endLC);
    > }
    >
    > Hope it Helps!
    >
    > "d[ - - ]b" <nospamplz@goaway.xyz> wrote in message
    news:<c8bsm7$ouv$1@lust.ihug.co.nz>...
    > > Hi,
    > >
    > > Is it possible to align a template column? Tried align, textalign and
    > > itemstyle (but I think that one is for the whole grid?), and nothing
    works.
    > > It's a simple datagrid, but one field is a dollar ($) value, so I've had
    to
    > > do a TemplateColumn so that I could make it have the '$'-sign and the
    > > decimal places, but it's aligned to the left which is kinda ugly. Any
    ideas
    > > how to change this column alone or another way to do this?
    > >
    > > Many thanks,
    > > Naomi

    d[ - - ]b 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