Use .SetCardinal method to rearrange order in a gridview

G

guevara.diego

Hello Group !!

I've a web application with 3 buttons (Order A, Order B, Order C), 1
gridview , the principal idea is enable the possibility to re-arrange
the columns order clicking in each button. I've this code...

DataSet dsTest;
DataTable dtOrder1;
public string thisConnectionString =

ConfigurationManager.ConnectionStrings["Employees_ConnectionString"].ConnectionString;

protected void Page_Load(object sender, EventArgs e)
{


dtOrder1 = new DataTable();
SqlConnection sqlConex = new
SqlConnection(thisConnectionString);
SqlDataAdapter daTables = new SqlDataAdapter("Select * from
Employee", sqlConex);
daTabla.Fill(dtOrder1);

grd01.DataSource = dtOrder1;
grd01.DataBind();
}



protected void btn1_Click(object sender, EventArgs e)
{


dtOrder1.Columns[0].SetOrdinal(2);
dtOrder1.Columns[1].SetOrdinal(1);
dtOrder1.Columns[2].SetOrdinal(0);
grd01.DataSource = dtOrder1;
grd01.DataBind();

}



But doesn't works ... what's the problem ??... any idea ??



Thanks a lot
 

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

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top