Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
45
populate asp dropdownlist in ultrawebgrid
posted

Hi,

 

I've put a asp:dropdownlist inside a templated column in a ultrawebgrid. I would like to populate dinamically the dropdownlist in C#. How can I do that?

 

Thanks,

PSC

Parents
No Data
Reply
  • 15979
    Suggested Answer
    posted

     Hello pedrosacosta,

    You can use this code in InitializeLayout() event (or other needed event) in order to get the embedded control and assign needed properties to it:

    //create a variable for the templated column in the WebGrid
    TemplatedColumn templatedColumn = (TemplatedColumn) this.UltraWebGrid1.Columns.FromKey("TemplatedColumn");

    //get a cellitem reference in the cellitems collection
    CellItem cellItem = (CellItem) templatedColumn.CellItems[myRowIndex];

    //find the control
    Control cs = cellItem.FindControl("<controlID>");

    //cast the control into the correct type
    <ControlType> <name> = (<ControlType>) cs;

    <name>.DataSource = ...;

    <name>.<property> = ....;

    In this way you can access the embedded control and assign values or properties to it.

Children
No Data