Hi

void BindDataSource()
{
System.Web.UI.WebControls.BoundColumn c1 = new
System.Web.UI.WebControls.BoundColumn();
c1.DataField = "CustomerID";
c1.HeaderText = "Customer ID";

System.Web.UI.WebControls.BoundColumn c2 = new
System.Web.UI.WebControls.BoundColumn();
c2.DataField = "Country";
c2.HeaderText = "Country";
grdCustomers.Columns.AddAt(grdCustomers.Columns.Co unt -1,c1); /* See I
am using AddAt instead of Add */
grdCustomers.Columns.AddAt(grdCustomers.Columns.Co unt -1,c2);

SqlConnection conn = new
SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
SqlCommand cmd = new SqlCommand("Select Top 5 CustomerID,Country From
Customers",conn);
conn.Open();
SqlDataReader dr = cmd.ExecuteReader();
grdCustomers.DataSource = dr;
grdCustomers.DataBind();
conn.Close();
}

HTH
Prasad
"Robert Scheer" <rbscheermy-deja.com> wrote in message
news:cfd22ab6.0307070838.35ac79e2posting.google.c om...
> Hi.
>
> I have a Datagrid with autogeneratecolumns set to false. All my
> columns are defined in my code-behind file except that I need to add a
> template column at the end of the datagrid. This last columns doesn't
> need to be coded because it is very simple but when I add the template
> column to the grid using the Property Builder and run my code it
> becomes the first column of the grid instead of the last one. How can
> I make this template column the last column of the grid?
>
> Thanks,
>
> Robert Scheer