Hi,
I am not having much luck getting input data from a table that is dynamically created within a radpanel and am hoping someone could tell me what I am doing wrong.
The table (IndexTable) is created dynamically
The table is displayed just fine but I can't retrieve any of the data that I input into cell 2. I have a "Submit" button that calls javascript to get the data but all I get is the label data, cell 1.
I know I must be doing something wrong but I don't know what. Can anyone help me?
Thanks
I am not having much luck getting input data from a table that is dynamically created within a radpanel and am hoping someone could tell me what I am doing wrong.
| <! -- Index data -----------> |
| <telerik:RadPanelBar runat="server" ID="RadPanelBar1" |
| ExpandMode="FullExpandedItem" Width="98%" Height="50%" > |
| <Items> |
| <telerik:RadPanelItem Expanded="True" Text="Index Information" Selected="true"> |
| <Items> |
| <telerik:RadPanelItem Value="IndexInformation" > |
| <ItemTemplate> |
| <asp:Table ID="IndexTable" runat="server" EnableViewState="false" > |
| </asp:Table> |
| </ItemTemplate> |
| </telerik:RadPanelItem> |
| </Items> |
| </telerik:RadPanelItem> |
| </Items> |
| </telerik:RadPanelBar> |
The table (IndexTable) is created dynamically
| IndexTable.Rows.Clear(); |
| //load the custom indexes |
| foreach (int idx in ur.AllIndexes) |
| { |
| if (rd.IndexMap.ContainsKey(idx)) |
| { |
| CIndex cIndex = rd.IndexMap[idx]; |
| Label lbl = new Label(); |
| lbl.ID = idx.ToString() + "Label"; |
| lbl.Text = cIndex.IndexComponents[1].Label; |
| lbl.Visible = true; |
| TableRow tr = new TableRow(); |
| // Create column 1 |
| TableCell td1 = new TableCell(); |
| // Create a label control dynamically |
| Label _label = new Label(); |
| _label.ID = idx.ToString() + "Label"; |
| _label.Text = cIndex.IndexComponents[1].Label; |
| // Add control to the table cell |
| td1.Controls.Add(_label); |
| // Create column 2 |
| TableCell td2 = new TableCell(); td2.Visible = true; |
| } |
| // Add cell to the row tr.Cel |
| tr.Cells.Add(td1); |
| tr.Cells.Add(td2); |
| // Add row to the table. |
| IndexTable.Rows.Add(tr); |
| } |
The table is displayed just fine but I can't retrieve any of the data that I input into cell 2. I have a "Submit" button that calls javascript to get the data but all I get is the label data, cell 1.
| <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"> |
| <script type="text/javascript"> |
| function GetIndexData() { |
| var test = ""; |
| var tblIndex = $get('<%= ((Table)RadPanelBar1.FindItemByValue("IndexInformation").FindControl("IndexTable")).ClientID %>'); |
| var RowsLength = tblIndex.rows.length; |
| for (var i = 0; i < RowsLength; i++) { |
| var oCells = tblIndex.rows.item(i).cells; |
| var CellsLength = oCells.length; |
| for (var j = 0; j < CellsLength; j++) { |
| alert(oCells.item(j).innerHTML); |
| } |
| } |
| } |
| </script> |
| </telerik:RadCodeBlock> |
I know I must be doing something wrong but I don't know what. Can anyone help me?
Thanks