This is a migrated thread and some comments may be shown as answers.
Disabled GridButtonColumn confirmtext
3 Answers 49 Views
This is a migrated thread and some comments may be shown as answers.
Ken
Top achievements
Rank 1
Ken asked on 11 Feb 2011, 04:53 PM
After disabling the buttoncolumn in a grid when clicked the confirm text still shows. The button does not fire which is good. how do I keep the confirm text from showing. I tried the following which does not work.

protected void RadGrid1_PreRender(object sender, EventArgs e)
        {
            foreach (GridDataItem DataItem in RadGrid1.Items)
            {
                if (DataItem["Import"].Text == "0")
                {
                    DataItem["ImportColumn"].Enabled = false;
  
                    TableCell cell = (TableCell)DataItem["ImportColumn"];
                    cell.Enabled = false;
  
                }
            }



3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 14 Feb 2011, 06:40 AM
Hello Ken,


Try the following code instead to get it working.

Code in ItemDataBound event:
  protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
  {
      if (e.Item is GridDataItem)
      {
          GridDataItem item = (GridDataItem)e.Item;
          if (item["Import"].Text == "0")
          {
              Button btn = (Button)item["ImportColumn"].Controls[0];
              btn.Enabled = false;
          }
      }
}

And the mark-up will be:
. . .
      <telerik:GridButtonColumn Text="Delete this" ConfirmText="Are you sure?" ButtonType="PushButton" HeaderText="ButtonColumn"   UniqueName="ImportColumn">
       </telerik:GridButtonColumn>



Thanks,
Princy.
0
Richard
Top achievements
Rank 1
answered on 08 May 2014, 06:40 PM
I need to do something similar but with a default link button. I would like to disable the link but still display the text data based on user role.
Casting as Button fails because column type is GridLinkButton. I am not using ButtonType = ?? in mark up

In radGrid_ItemDataBound  how do I cast the button as a GridLinkButton? And will Enabled = false do what I want?
               
                GridLinkButton btn = (GridLinkButton)item["colAccountNumber"].Controls[0];
                btn.Enabled = false;
0
Richard
Top achievements
Rank 1
answered on 08 May 2014, 06:47 PM
I found it. Buttontype="LinkButton" works fine
Tags
Grid
Asked by
Ken
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Richard
Top achievements
Rank 1
Share this question
or