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

[Solved] how to change gridbuttoncolumn image/text change at runtime

4 Answers 1028 Views
Grid
This is a migrated thread and some comments may be shown as answers.
RJ
Top achievements
Rank 1
RJ asked on 10 Sep 2009, 02:11 PM
How can I change GridButtonColumn text/image at runtime. Text or image will ba based on grids data.

Im using asp.net ajax 2009 Q1
Thanks in advance.

4 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 11 Sep 2009, 04:30 AM
Hello,

Try the following code snippet in order to change the text/image of GridButtonColumn dynamically.

ASPX:
 
<telerik:GridButtonColumn Text="MyButton" UniqueName="MyButton" CommandName="MyButtonClick"
            </telerik:GridButtonColumn> 
<telerik:GridButtonColumn ButtonType="ImageButton" ImageUrl="~/images/Image1.gif" 
                UniqueName="print" Text="Print "
            </telerik:GridButtonColumn> 

CS:
 
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    if (e.Item is GridDataItem) 
    { 
        GridDataItem item = (GridDataItem)e.Item; 
        if (item["CustomerID"].Text == "ALFKI"
        { 
            (item["MyButton"].Controls[0] as LinkButton).Text = "ALFKI"
            (item["print"].Controls[0] as ImageButton).ImageUrl = "~/images/Image2.png"
        } 
    } 

-Shinu.
0
RJ
Top achievements
Rank 1
answered on 11 Sep 2009, 06:21 AM
Thanks a lot shinu
0
RJ
Top achievements
Rank 1
answered on 25 Sep 2009, 06:41 PM

Hi Shinu,

How can I apply the same principle for DetailTable?

Thanks,
RJ

 

0
RJ
Top achievements
Rank 1
answered on 28 Sep 2009, 08:52 PM
I was able to make it work with detailtable using the e.item.ownertableview.name in item databound.
Tags
Grid
Asked by
RJ
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
RJ
Top achievements
Rank 1
Share this question
or