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

Radgrid EditCommand Column and Button Column

4 Answers 252 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ashwin Deshpande
Top achievements
Rank 1
Ashwin Deshpande asked on 17 Aug 2010, 11:25 AM
I M Using a Radgrid in which i need to disable radgrid Commnds on Some DataItem ..
I m using RadgridEditCommand Column as well asRadgridbutton Column.
Even if i make them enable false..Clicking on that itemCommand gets fired.


 

Private Sub DisableRadGridCommand(ByVal dtitem As GridDataItem, ByVal colname As String)

 

 

Try

 

 

For Each ctrl In dtitem(colname).Controls

 

 

If (TypeOf ctrl Is WebControl) Then

 

 

CType(ctrl, WebControl).Enabled = False

 

 

End If

 

 

Next

 

 

Catch ex As Exception

 

 

End Try

 

 

End Sub

 

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 17 Aug 2010, 12:51 PM
Hello Ashwin,

You can try the following method to disable grid commands for some rows.

ASPX:
<telerik:GridEditCommandColumn UniqueName="EditCommandColumn">
</telerik:GridEditCommandColumn>
<telerik:GridButtonColumn Text="Delete" UniqueName="GridButtonColumn">
</telerik:GridButtonColumn>

VB.Net:
Protected Sub RadGrid1_ItemDataBound(sender As Object, e As GridItemEventArgs)
    If TypeOf e.Item Is GridDataItem Then
        Dim item As GridDataItem = DirectCast(e.Item, GridDataItem)
        If item("EmployeeID").Text = "3" Then
            'set your conditon
            item("EditCommandColumn").Enabled = False
            item("GridButtonColumn").Enabled = False
        End If
    End If
End Sub

Thanks,
Princy.
0
Pradeep
Top achievements
Rank 2
answered on 29 Jun 2012, 03:28 PM
Hello,

How would I do this on a child grid ?

I want to disable edit mode for rows in a child grid ?.

Thanks,

Pradeep
0
Shinu
Top achievements
Rank 2
answered on 02 Jul 2012, 04:31 AM
Hello Pradeep,

Try the following code to achieve your scenario.
C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
 if (e.Item is GridDataItem && e.Item.OwnerTableView.Name == "Details")
 {
   GridDataItem item = (GridDataItem)e.Item;
   if (item["UniqueName"].Text == "text")
    {
      item["Edit"].Enabled = false;
    }
 }
}

Thanks,
Shinu.
0
Distribuidora Electrica
Top achievements
Rank 1
answered on 10 Jul 2012, 05:59 PM
I've tried that solution for a hierarchy with EditMode=InPlace in the detail, but when pressing the Edit link, it does not show the Update link, only the Cancel one.
Is there anything else to consider in the case of inplace editing in the detail of a hierarchy?

Thanks in advance.
Tags
Grid
Asked by
Ashwin Deshpande
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Pradeep
Top achievements
Rank 2
Shinu
Top achievements
Rank 2
Distribuidora Electrica
Top achievements
Rank 1
Share this question
or