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

Unable to find control in RadGridView

4 Answers 197 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Johny
Top achievements
Rank 2
Johny asked on 28 Mar 2010, 08:05 AM

Hi

I’m very new with the telerik, I’m trying to find a control from radGridview.I implements in .Net Grid control ( sample code is given below) But I cant do the same in radGridView. Can anyone give me any idea to implement this in radGridview. I need your help.

Code snippets:

        foreach (GridViewRow row in dgrdInbox.Rows)

        {

          

            CheckBox cbBox = (CheckBox)row.FindControl("cbYesNo");

             

           if (cbYesOrNo.Checked)

            {

                  // Do something

}

else

{

// Do something

}

                    }

 

 

Thanks in advanced. 

Md. Marufuzzaman

4 Answers, 1 is accepted

Sort by
0
Svett
Telerik team
answered on 29 Mar 2010, 02:08 PM
Hello Johny,

Thank you for supplied code snippet.

Presently, the controls in the suite do not use other controls to achieve their functionality. They use special elements of type RadElement.  It is the basic object in Telerik Presentation Framework used for implementation of RadControls for Winforms. You can read more about TPF in this documentation article.

The fastest approach to get the desired value of specified column for each row is to go through the collection of Rows of the grid. You can use the following code snippet as sample:

foreach (GridViewDataRowInfo dataRow in this.radGridView.Rows)
{
    bool value = Convert.ToBoolean(dataRow.Cells["BoolColumn"].Value);
 
    if (value)
    {
        // TO DO: Your code when the value is true
    }
    else
    {
        // TO DO: Your code when the value is false
    }
}

If you have further questions feel free to write us back.

Sincerely yours,
Svett
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.
0
Johny
Top achievements
Rank 2
answered on 29 Mar 2010, 03:41 PM
Hi Svett:

Thanks for your reply with sample code snippets, probably there is an issue of NULL value, this code will throw an exception when
thedataRow.Cells["BoolColumn"].Value is NULL. Actually I'm facing an error that is (exception = {"Object cannot be cast from DBNull to other types."}). Any suggestion for this

Thanks
Md. Marufuzzaman
 

0
Accepted
Svett
Telerik team
answered on 01 Apr 2010, 10:08 AM
Hi Johny,

Thank you for the clarification. You are receiving this exception because the Boolean cell for the specified row has a null value. Hence, .NET Framework Convert class throws exception. Therefore, you can modify the code snippet as it is shown below:
foreach (GridViewDataRowInfo dataRow in this.radGridView.Rows)
{
    bool value = false;
 
    if (dataRow.Cells["BoolColumn"].Value != null && !(dataRow.Cells["BoolColumn"].Value is DBNull))
    {
        value = Convert.ToBoolean(dataRow.Cells["BoolColumn"].Value);
    }
 
    if (value)
    {
        // TO DO: Your code when the value is true
    }
    else
    {
        // TO DO: Your code when the value is false
    }
}

If you need further assistance, do not hesitate to ask.

Greetings,
Svett
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.
0
Johny
Top achievements
Rank 2
answered on 01 Apr 2010, 03:12 PM
Hi Svett:
    Thanks a lot :)

Regards,
Md. Marufuzzaman
Tags
GridView
Asked by
Johny
Top achievements
Rank 2
Answers by
Svett
Telerik team
Johny
Top achievements
Rank 2
Share this question
or