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

Radgrid Row Controls collection client side

1 Answer 84 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Clifton Brown
Top achievements
Rank 1
Clifton Brown asked on 13 Apr 2009, 04:08 PM
Hello,

I need to be able to add dynamically created textboxes to my Grid rows. I'm doing that in the grid's ItemCreated event. However, on post back my text boxes are being recreated and therefore losing their values. I don't want to have to recreat my textbox controls in Page_Init. I had an idea to read the textbox values on the client side and write them to a hidden field control. The problems is that I can't figure out how to access the SelectedRow's controls collection to find my text boxes.
Also, the number of text boxes per row is also dynamic. Meaning Row 1 may have just 1 textbox while Row 2 has 3. This is why  i need to be able to dynamically loop the row's controls since I won't know exactly how many text boxes were created for a given row
Here is what I'm trying to do

 

function RowSelected(row)

 

{

 

 

    for (i=0;i<row.Controls.count;i++)

 

    {

 

        if (row.Controls[i].type == "text")//if the type of control is textbox

 

        {

            alert(row.Controls[i].id);

        }

    }

 

 

 

}

I'm getting a javascript error that controls.count is null

How can  I accomplish this task? It's doesn't have to be the same solution as outlined above. I just need to be able to create those text boxes at run time and access their values on the server at postback.

Thanks in advance ;)

1 Answer, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 16 Apr 2009, 01:09 PM
Hi Clifton,

Could you please elaborate a bit on your scenario as I am not sure I do properly understand what you are trying to achieve?
You said that the TextBox controls are added on ItemCreated, but when what text are you setting to them? And what actions are performed so their text is lost?

Sincerely yours,
Iana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Clifton Brown
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Share this question
or