Home All Groups Group Topic Archive Search About

Move bound column to right of dynamic column in datagrid?

Author
24 Mar 2005 11:23 PM
John E.
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

Author
24 Mar 2005 11:59 PM
Elton Wang
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
elton_w***@hotmail.com


>-----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
Show quoteHide quote
>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
Show quoteHide quote
>to get it to be added to the right side of the DataTable,
instead?
>
>Any help appreciated.
>Thanks,
>-John
>
>
>.
>
Author
25 Mar 2005 3:12 PM
John E.
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

Show quoteHide quote
"Elton Wang" <anonym***@discussions.microsoft.com> wrote in message
news:0f9f01c530cd$829fd930$a401280a@phx.gbl...
> 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
> elton_w***@hotmail.com
>
>
> >-----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
> >
> >
> >.
> >
Author
28 Mar 2005 1:29 PM
Elton Wang
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
Show quoteHide quote
>not work either.  The "edit" is still on the left side.
>
>Any other ideas?
>
>Thank you,
>-John
>
>"Elton Wang" <anonym***@discussions.microsoft.com> wrote
in message
>news:0f9f01c530cd$829fd930$a401280a@phx.gbl...
>> 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
>> elton_w***@hotmail.com
>>
>>
>> >-----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
>> >
>> >
>> >.
>> >
>
>
>.
>