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

[Solved] Changing text in hierarchy grid

3 Answers 113 Views
Grid
This is a migrated thread and some comments may be shown as answers.
pradeep k
Top achievements
Rank 1
pradeep k asked on 17 Nov 2009, 01:16 PM
Hi All,

I have a hierarchy grid, in master table view i have a column called "Status" (values will be like A,I) and in child table i have column called "Status1" (values will be like O,C)

now i want to change the Status, Status1 text as Active,Inactive and Open,Close respectively.

How can i do this in C#, Please help me regarding this.

3 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 17 Nov 2009, 01:52 PM
Hello,

You should use the ItemDataBound server event of RadGrid to change the cells' text. Access the respective table cell by using the column's UniqueName, as demonstrated here:

http://www.telerik.com/help/aspnet-ajax/grdaccessingcellsandrows.html

Kind regards,
Dimo
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
pradeep k
Top achievements
Rank 1
answered on 17 Nov 2009, 02:17 PM
Thanks for the reply,

I am able to change the text for the master table columns,

after i am trying to do the same for the child table, then it is showing error called column not found.
0
pradeep k
Top achievements
Rank 1
answered on 17 Nov 2009, 02:47 PM
I got the solution.

protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
        {
            try
            {
                if (e.Item.OwnerTableView.Name == "ChildTableName")
                {
                    if (e.Item is GridDataItem)
                    {
                        GridDataItem item = (GridDataItem)e.Item;

                        if (item["SupplierStatus"].Text == "A")
                        {
                            item["SupplierStatus"].Text = "Active";
                        }
                        else if (item["SupplierStatus"].Text == "I")
                        {
                            item["SupplierStatus"].Text = "Inactive";
                        }
                    }
                }
                else
                {
                    if (e.Item is GridDataItem)
                    {
                        GridDataItem item = (GridDataItem)e.Item;

                        if (item["ContractStatus"].Text == "A")
                        {
                            item["ContractStatus"].Text = "Approved";
                        }
                        else if (item["ContractStatus"].Text == "C")
                        {
                            item["ContractStatus"].Text = "Closed";
                        }
                        else if (item["ContractStatus"].Text == "O")
                        {
                            item["ContractStatus"].Text = "Open";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageLabel.Visible = true;
                MessageLabel.Text = ex.Message;
            }       
        }
Tags
Grid
Asked by
pradeep k
Top achievements
Rank 1
Answers by
Dimo
Telerik team
pradeep k
Top achievements
Rank 1
Share this question
or