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

Add a .gif to delete column?

3 Answers 114 Views
Grid
This is a migrated thread and some comments may be shown as answers.
derek
Top achievements
Rank 2
derek asked on 25 Mar 2009, 08:00 PM
Instead of using a link with "Delete", how can I use a .gif instead or ImageUrl for AutoGenerateDeleteColumn?

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 26 Mar 2009, 04:51 AM
Hi Derek,

Try any one of the following approach and see whether it helps.

CS:
 
 
protected void RadGrid1_PreRender(object sender, EventArgs e) 
    { 
 
        GridButtonColumn btncol = (GridButtonColumn)RadGrid1.MasterTableView.GetColumn("AutoGeneratedDeleteColumn"); 
        btncol.ButtonType = GridButtonColumnType.ImageButton; 
        btncol.ImageUrl = "~/Images/Delete.gif"
        RadGrid1.MasterTableView.Rebind(); 
        
        
    } 

or
 
 
 protected void RadGrid1_ColumnCreated(object sender, GridColumnCreatedEventArgs e) 
    { 
        if (e.Column.UniqueName == "AutoGeneratedDeleteColumn"
        { 
            (e.Column as GridButtonColumn).ButtonType = GridButtonColumnType.ImageButton; 
            (e.Column as GridButtonColumn).ImageUrl = "~/Images/Delete.gif"
        } 
    } 


Shinu
0
derek
Top achievements
Rank 2
answered on 26 Mar 2009, 03:33 PM
AWESOME, thank you so much.  I tried adding an image for the update column like this:

protected void RadGrid1_ColumnCreated(object sender, GridColumnCreatedEventArgs e)  
    {  
        if (e.Column.UniqueName == "AutoGeneratedDeleteColumn")  
        {  
            (e.Column as GridButtonColumn).ConfirmText = "Are you Sure you want to delete this record?  Did you ask Bryan?";  
            (e.Column as GridButtonColumn).ButtonType = GridButtonColumnType.ImageButton;  
            (e.Column as GridButtonColumn).ImageUrl = "~/NewFolder1/delete.gif";  
        }  
        if (e.Column.UniqueName == "AutoGeneratedUpdateColumn")  
        {  
            (e.Column as GridButtonColumn).ButtonType = GridButtonColumnType.ImageButton;  
            (e.Column as GridButtonColumn).ImageUrl = "~/NewFolder1/update.gif";  
        } 

But the Edit link still shows. 
0
derek
Top achievements
Rank 2
answered on 26 Mar 2009, 03:49 PM
So I also tried this:

protected void RadGrid1_ColumnCreated(object sender, GridColumnCreatedEventArgs e)  
    {  
        if (e.Column.UniqueName == "AutoGeneratedDeleteColumn")  
        {  
            (e.Column as GridButtonColumn).ConfirmText = "Are you Sure you want to delete this record?  Did you ask Bryan?";  
            (e.Column as GridButtonColumn).ButtonType = GridButtonColumnType.ImageButton;  
            (e.Column as GridButtonColumn).ImageUrl = "~/NewFolder1/delete.gif";  
        }  
        if (e.Column.UniqueName == "AutoGeneratedEditColumn")  
        {  
            (e.Column as GridButtonColumn).ButtonType = GridButtonColumnType.ImageButton;  
            (e.Column as GridButtonColumn).ImageUrl = "~/NewFolder1/update.gif";  
        } 

But then after I publish it, I get an error of "Object reference not set to an instance of an object."
Tags
Grid
Asked by
derek
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
derek
Top achievements
Rank 2
Share this question
or