Move bound column to right of dynamic column in datagrid?

J

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
 
E

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
(e-mail address removed)
 
J

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
 
E

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,007
Latest member
obedient dusk

Latest Threads

Top