locked
Not able to view the property of rendered control. RRS feed

  • Question

  • User939516264 posted

    I am creating BarGraph control which takes NumberOfBars and Heights from the user, with the following code

    public class BarChart : Control, INamingContainer

    {

          [
    Bindable(true)]

          private int _NumberOfBars;

          public int NumberOfBars

          {

                get

                {

                      return _NumberOfBars;

                }

                set

                {

                      _NumberOfBars =
    value;

                }

          }

          private string[ ] Heights;      public string this[int i]

          {

                get

                {

                      return Heights[i];

                }

                set

                {

                      Heights[i] =
    value;

                }

          }

          protected override void Render(HtmlTextWriter writer)

          {

                //Control definition goes here

          }

    }

    In a form, on the click of a button, I am assigning the values to the two properties

    BarChart1.NumberOfBars = Convert.ToInt32(txtNumberOfBars);

    BarChart1.Heights = txtHeights.Text.Split(',', Convert.ToInt32(txtNumberOfBars.Text), StringSplitOptions.None);  **

     

    The property NumberOfBars in available on the form on which I am using the Rendered control, but the property Heights in not.

    Following are the errors that are arising, all of them in the same line, that I have marked **

    'DynamicBars.BarChart' does not contain definition for 'Heights'

    The best overloaded method for 'string.Split (params char[])' has some invalid arguments.

    Argument '2': Cannot convert from 'int' to 'char'

    Argument '3': Cannot convert from 'StringSplitOptions' to 'char'

    Saturday, March 29, 2008 8:47 AM

Answers

  • User-1581724896 posted

    Kush,

    The Height property is also available on the form. But as you have takn an array of the Heights and you are trying to split based on the comma ',', it is here which is causing the problem. Try making the Height property an Int property and then try to assign one height value. Check if this works. This means that Height is available on your page. Then build on the array.

    ---------------------------------------------------------------------

    Please click Mark As Answer if this helped in solving your problem.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, March 29, 2008 10:51 AM