Not recognizing a linkbutton in a data grid.

2 posts, 0 answers
  1. Selvaprabu
    Selvaprabu avatar
    3 posts
    Member since:
    Nov 2011

    Posted 08 Dec 2011 Link to this post

    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.
  2. Anthony
    Admin
    Anthony avatar
    19 posts

    Posted 12 Dec 2011 Link to this post

    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
Back to Top