Please Help!!!

  • Thread starter Thread starter HalaszJ
  • Start date Start date
H

HalaszJ

I have 2 Questions that I cant seem to find the answers for. How can I
create a programmatic datagrid sort? And how can I use a
hyperlinkcolumn and have it pass the id of the item where the event
was clicked?


dg.AutoGenerateColumns = false;
dg.AllowSorting = true;
dg.SortCommand += new DataGridSortCommandEventHandler(dgSort);

BoundColumn tID = new BoundColumn();
tID.DataField = "TERMINALID";
tID.HeaderText = "Terminal ID";
tID.SortExpression = "t.terminalid";

HyperLinkColumn mID = new HyperLinkColumn();
mID.DataTextField = "MERCHANTID";
mID.NavigateUrl = "http://localhost/cams/configuration/merchants/main.aspx?
merchantid='NEED SELECTED ITEM ID HERE'";
mID.HeaderText = "Merchant ID";
mID.SortExpression = "m.merchantid";
....

dg.Columns.Add(tID);
dg.Columns.Add(mID);

....

cn.Open();
dg.DataSource = cmd.ExecuteReader();
dg.DataBind();
 
Use a DataView and use it's sort method. Dim dv as Dataview =
yourDataTable.DefaultView

then dv.Sort(ColumnIndex)



The grid will have a OnSortCommand Event, so you which pases in Source as
Object ad DataGridSortCommadnEventArgs...you can trap e as you wish.

HTH.

Bill
 
Back
Top