This is a migrated thread and some comments may be shown as answers.

GridButtonColumn with ImageButton as Button Type

1 Answer 140 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Greg
Top achievements
Rank 1
Greg asked on 24 Nov 2008, 04:25 PM
Here is a portion of my code I am using.  I have a RadGrid that I am adding columns to programmatically.  If I the "removeCol" object as a LinkButton, the TemplateGrid.ItemCommand event fires.  However, if I set the ButtonType to ImageButton, all the page does is PostBack.

Any suggestion???

protected void Page_Load(object sender, EventArgs e)
        {
......
TemplateGrid.ItemCommand += TemplateGrid_ItemCommand;
            TemplateGrid.NeedDataSource += TemplateGrid_NeedDataSource;
            TemplateGrid.Rebind();   
......
}
private void CreateGridColumns()
{
.....
            GridButtonColumn removeCol = new GridButtonColumn();
            TemplateGrid.MasterTableView.Columns.Add(removeCol);
            removeCol.CommandName = RadGrid.DeleteCommandName;
            removeCol.UniqueName = "DeleteColumn";                
            removeCol.ImageUrl = Presenter.ResourceService.GetImageUrl("toolbars", "delete_small.gif");
            removeCol.ButtonType = GridButtonColumnType.ImageButton;
........
}

1 Answer, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 25 Nov 2008, 12:56 PM
Hello Greg,

You should not call Rebind() in every page lifecycle. This will clear the grid child controls and ViewState and will cause lots of problems.

Kind regards,
Vlad
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Greg
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Share this question
or