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

Not recognizing a linkbutton in a data grid.

1 Answer 102 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Selvaprabu
Top achievements
Rank 1
Selvaprabu asked on 08 Dec 2011, 06:50 AM
Tool is recognizing the grid and all the contents , but it doesn’t reads the linkbutton in the grid.
For example I have test data grid with following columns :
Name,Email and Designation.
In the above column Name and Email are text but Designation is the linkbutton.When i read the values from the grid tool reads Name and EMail but it doesn't reads the Designation.

I have used the following code to read the values from the grid.

foreach (HtmlTableRow r in Pages.Http172160.DgTestDataTable.AllRows)
            {
                foreach (HtmlTableCell c in r.Cells)
                {
                    Log.WriteLine("Identifying Grid Items:"+c.TextContent);
                }
                
            }


Please refer the attached Sample Code used.

1 Answer, 1 is accepted

Sort by
0
Anthony
Telerik team
answered on 12 Dec 2011, 06:45 PM
Hi Selvaprabu,

The issue is that for Name and Email, the text content belongs to the actual cell, so it's read properly. The text content of Designation, however, belongs the the child button element, so the text content of that cell is actually empty.

I modified your code to account for this:

foreach (HtmlTableRow r in Pages.CHTMLCommaHtml.Table.AllRows)
{
    foreach (HtmlTableCell c in r.Cells)
    {
        if (!string.IsNullOrEmpty(c.TextContent)) //If the cell's text content is not null or empty, write it to the log.
        {
            Log.WriteLine("Identifying Grid Items:" + c.TextContent);
        }
        else
        {
            foreach (Element e in c.ChildNodes) //Otherwise, write the text content of each child element in the cell to the log.
            {
                Log.WriteLine("Identifying Grid Items:" + e.TextContent);
            }
        }
    }
}
 

Greetings,
Anthony
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
General Discussions
Asked by
Selvaprabu
Top achievements
Rank 1
Answers by
Anthony
Telerik team
Share this question
or