Move bound column to right of dynamic column in datagrid?

Discussion in 'ASP .Net Datagrid Control' started by John E., Mar 24, 2005.

  1. John E.

    John E. Guest

    I have a datatable that I am binding to a C# ASP.NET 1.1 web page. I also
    want to put an "Edit" column on the datagrid. However, whenever I use the
    following code, it puts the Edit column on the left. I cannot figure out
    how to get it to the right, as there is no DataGridTableStyle for ASP as
    there is for an application.
    I am doing the following on page load: (where dgItem is my datagrid):

    EditCommandColumn EditColumn = new EditCommandColumn();
    EditColumn.ButtonType = ButtonColumnType.LinkButton;
    EditColumn.CancelText = "Cancel";
    EditColumn.EditText = "Edit";
    EditColumn.HeaderText = "Edit";
    EditColumn.UpdateText = "Save";

    dgItem.DataSource = ReturnsPopulatedDataTable();
    dgItem.Columns.AddAt(1, EditColumn);
    dgItem.DataBind();

    The edit column keeps showing up on the far left of the grid. Any ideas how
    to get it to be added to the right side of the DataTable, instead?

    Any help appreciated.
    Thanks,
    -John
    John E., Mar 24, 2005
    #1
    1. Advertising

  2. John E.

    Elton Wang Guest

    Hi John,

    Instead

    dgItem.Columns.AddAt(1, EditColumn);

    You can use

    dgItem.Columns.AddAt(dgItem.Columns.Count, EditColumn);

    to put Edit column on the right side.

    HTH

    Elton Wang



    >-----Original Message-----
    >I have a datatable that I am binding to a C# ASP.NET 1.1

    web page. I also
    >want to put an "Edit" column on the datagrid. However,

    whenever I use the
    >following code, it puts the Edit column on the left. I

    cannot figure out
    >how to get it to the right, as there is no

    DataGridTableStyle for ASP as
    >there is for an application.
    >I am doing the following on page load: (where dgItem is

    my datagrid):
    >
    >EditCommandColumn EditColumn = new EditCommandColumn();
    >EditColumn.ButtonType = ButtonColumnType.LinkButton;
    >EditColumn.CancelText = "Cancel";
    >EditColumn.EditText = "Edit";
    >EditColumn.HeaderText = "Edit";
    >EditColumn.UpdateText = "Save";
    >
    >dgItem.DataSource = ReturnsPopulatedDataTable();
    >dgItem.Columns.AddAt(1, EditColumn);
    >dgItem.DataBind();
    >
    >The edit column keeps showing up on the far left of the

    grid. Any ideas how
    >to get it to be added to the right side of the DataTable,

    instead?
    >
    >Any help appreciated.
    >Thanks,
    >-John
    >
    >
    >.
    >
    Elton Wang, Mar 24, 2005
    #2
    1. Advertising

  3. John E.

    John E. Guest

    Thanks for the response! Unfortunately I had tried that earlier and it does
    not work either. The "edit" is still on the left side.

    Any other ideas?

    Thank you,
    -John

    "Elton Wang" <> wrote in message
    news:0f9f01c530cd$829fd930$...
    > Hi John,
    >
    > Instead
    >
    > dgItem.Columns.AddAt(1, EditColumn);
    >
    > You can use
    >
    > dgItem.Columns.AddAt(dgItem.Columns.Count, EditColumn);
    >
    > to put Edit column on the right side.
    >
    > HTH
    >
    > Elton Wang
    >
    >
    >
    > >-----Original Message-----
    > >I have a datatable that I am binding to a C# ASP.NET 1.1

    > web page. I also
    > >want to put an "Edit" column on the datagrid. However,

    > whenever I use the
    > >following code, it puts the Edit column on the left. I

    > cannot figure out
    > >how to get it to the right, as there is no

    > DataGridTableStyle for ASP as
    > >there is for an application.
    > >I am doing the following on page load: (where dgItem is

    > my datagrid):
    > >
    > >EditCommandColumn EditColumn = new EditCommandColumn();
    > >EditColumn.ButtonType = ButtonColumnType.LinkButton;
    > >EditColumn.CancelText = "Cancel";
    > >EditColumn.EditText = "Edit";
    > >EditColumn.HeaderText = "Edit";
    > >EditColumn.UpdateText = "Save";
    > >
    > >dgItem.DataSource = ReturnsPopulatedDataTable();
    > >dgItem.Columns.AddAt(1, EditColumn);
    > >dgItem.DataBind();
    > >
    > >The edit column keeps showing up on the far left of the

    > grid. Any ideas how
    > >to get it to be added to the right side of the DataTable,

    > instead?
    > >
    > >Any help appreciated.
    > >Thanks,
    > >-John
    > >
    > >
    > >.
    > >
    John E., Mar 25, 2005
    #3
  4. John E.

    Elton Wang Guest

    I don't know if your dgItem has any special setting,
    otherwise either
    dgItem.Columns.AddAt(dgItem.Columns.Count, EditColumn);
    or
    dgItem.Columns.Add(EditColumn);

    should locate EditColumn at right side.

    HTH

    Elton Wang

    >-----Original Message-----
    >Thanks for the response! Unfortunately I had tried that

    earlier and it does
    >not work either. The "edit" is still on the left side.
    >
    >Any other ideas?
    >
    >Thank you,
    >-John
    >
    >"Elton Wang" <> wrote

    in message
    >news:0f9f01c530cd$829fd930$...
    >> Hi John,
    >>
    >> Instead
    >>
    >> dgItem.Columns.AddAt(1, EditColumn);
    >>
    >> You can use
    >>
    >> dgItem.Columns.AddAt(dgItem.Columns.Count, EditColumn);
    >>
    >> to put Edit column on the right side.
    >>
    >> HTH
    >>
    >> Elton Wang
    >>
    >>
    >>
    >> >-----Original Message-----
    >> >I have a datatable that I am binding to a C# ASP.NET

    1.1
    >> web page. I also
    >> >want to put an "Edit" column on the datagrid. However,

    >> whenever I use the
    >> >following code, it puts the Edit column on the left. I

    >> cannot figure out
    >> >how to get it to the right, as there is no

    >> DataGridTableStyle for ASP as
    >> >there is for an application.
    >> >I am doing the following on page load: (where dgItem is

    >> my datagrid):
    >> >
    >> >EditCommandColumn EditColumn = new EditCommandColumn();
    >> >EditColumn.ButtonType = ButtonColumnType.LinkButton;
    >> >EditColumn.CancelText = "Cancel";
    >> >EditColumn.EditText = "Edit";
    >> >EditColumn.HeaderText = "Edit";
    >> >EditColumn.UpdateText = "Save";
    >> >
    >> >dgItem.DataSource = ReturnsPopulatedDataTable();
    >> >dgItem.Columns.AddAt(1, EditColumn);
    >> >dgItem.DataBind();
    >> >
    >> >The edit column keeps showing up on the far left of the

    >> grid. Any ideas how
    >> >to get it to be added to the right side of the

    DataTable,
    >> instead?
    >> >
    >> >Any help appreciated.
    >> >Thanks,
    >> >-John
    >> >
    >> >
    >> >.
    >> >

    >
    >
    >.
    >
    Elton Wang, Mar 28, 2005
    #4
    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. John E.
    Replies:
    3
    Views:
    4,438
    masoud bayan
    Mar 25, 2005
  2. sunil panda

    Lower bound & Upper bound

    sunil panda, Dec 25, 2003, in forum: Java
    Replies:
    9
    Views:
    7,206
    thushara wijeratna
    Oct 7, 2008
  3. Isaac Grover

    How to move this right column up

    Isaac Grover, Jun 18, 2007, in forum: HTML
    Replies:
    7
    Views:
    426
    Ben C
    Jun 18, 2007
  4. Ravichandran Mahalingam

    Bound Column or Template Column (w dAdapater?) in DataGrid

    Ravichandran Mahalingam, Jan 9, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    204
    Ravichandran Mahalingam
    Jan 9, 2004
  5. don

    update datagrid with dynamic bound column

    don, Apr 26, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    150
Loading...

Share This Page