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

Getting error in radgrid

2 Answers 41 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Janaki
Top achievements
Rank 1
Janaki asked on 22 May 2012, 08:32 AM
Hi all,
    In my radgrid there are 5 columns,and each column is having a link button in it. I need to check whether the name in column 3 is blank or not. And if the name field in the column 3 is blank I need to disable the link buttons in 4th and 5th columns. Below added my code and I am getting error with this. Please help me.

protected void GridSample_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
    foreach (GridDataItem item in GridSample.Items) {
        TableCell field_name = (TableCell)item("strName");
        if (field_name.Text == null) {
            Disable link buttons in columns 4 and 5.
        }
    }
}
Thanks in advance.

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 22 May 2012, 09:13 AM
Hi Janaki,

Try the following code snippet to disable the link buttons.

C#:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        GridDataItem ditem = (GridDataItem)e.Item;
        LinkButton linkbtn3 = (LinkButton)ditem["FirstName"].Controls[0];
        LinkButton linkbtn4 = (LinkButton)ditem["City"].Controls[0];
        LinkButton linkbtn5 = (LinkButton)ditem["FirstName1"].Controls[0];
        if (linkbtn3.Text == "")
        {
            linkbtn4.Enabled = false;
            linkbtn5.Enabled = false;
        }
    }
}

Thanks,
Princy.
0
Janaki
Top achievements
Rank 1
answered on 23 May 2012, 05:58 AM
Thanks
Tags
Grid
Asked by
Janaki
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Janaki
Top achievements
Rank 1
Share this question
or