Hi,
I've got a problem showing the correct ButtonType of Treelist command column at runtime, the command column ButtonType was set to ButtonType.Image but it always shows as link instead of Image.
I noticed that using Treelist.Columns.Assign() function to assign the Treelistcolumn collection doesn't render the correct button type, but when I use Treelist.Columns.Add() to add a command column, the image button shows up correctly. Please see my sample code snippet below, Thanks.
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack && !Page.IsCallback)
{
this.AssignColumns();
}
this.BindData();
}
private void BindData()
{
trListMain.DataSource = myDatasource;
trListMain.KeyFieldName = "GUID";
trListMain.ParentFieldName = "ParentGUID";
trListMain.DataBind();
trListMain.ExpandAll();
}
private void AssignColumns()
{
TreeListColumnCollection columnCollection = new TreeListColumnCollection(trListMain);
TreeListTextColumn code = new TreeListTextColumn();
TreeListTextColumn description = new TreeListTextColumn();
TreeListCommandColumn action = new TreeListCommandColumn();
code.Caption = "Code";
code.Name = "Code;
code.FieldName = "Code";
code.Width = Unit.Pixel(130);
columnCollection.Add(code);
description.Caption = "Description";
description.Name = "Description";
description.FieldName = "Description";
columnCollection.Add(description);
action.ButtonType = ButtonType.Image; << This doesn't work.
action.Width = Unit.Pixel(156);
action.Caption = "Action";
action.NewButton.Visible = true;
action.NewButton.Image.Url = "~/Images/Grid/ButtonNew.png";
action.NewButton.Image.Width = Unit.Pixel(78);
action.DeleteButton.Visible = true;
action.DeleteButton.Image.Url = "~/Images/Grid/ButtonDelete.png";
action.DeleteButton.Image.Width = Unit.Pixel(78);
action.UpdateButton.Visible = true;
action.UpdateButton.Image.Url = "~/Images/Grid/ButtonUpdate.png";
action.UpdateButton.Image.Width = Unit.Pixel(78);
action.CancelButton.Visible = true;
action.CancelButton.Image.Url = "~/Images/Grid/ButtonCancel.png";
action.CancelButton.Image.Width = Unit.Pixel(78);
action.EditButton.Visible = true;
action.EditButton.Image.Url = "~/Images/Grid/ButtonEdit.png";
action.EditButton.Image.Width = Unit.Pixel(78);
columnCollection.Add(action);
trListMain.Columns.Assign(columnCollection);
}