Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Oracle VB.NET
 
 Public Sub CreateTabl()
        Dim ScrObjects As New ScreenObjects
        Dim buLabl As New Label
        Dim tblBu As New Table
        Dim tr As TableRow
        Dim td As TableCell
        Dim tb As New Table
        'Dim txtbx As TextBox
        Dim ddlst As WebControls.DropDownList
 
        tb.Font.Size = 10
        tb.BorderWidth = 1
        tb.BorderStyle = BorderStyle.Solid
        tb.CellPadding = 4
        tb.CellSpacing = 0
        tb.ForeColor = Drawing.Color.Black
        tb.Width = 700
        tb.GridLines = GridLines.Both
        tb.Style.Add("align", "center")
        tb.Style.Add("text-align", "center")
 
        tr = New TableRow
        tr.ID = "trHdr"
        td = New TableCell
        td.Text = "Answer"
        td.ID = "tdAns"
        tr.Controls.Add(td)
        td = New TableCell
        td.Text = "Min Value"
        td.ID = "tdMinValue"
        tr.Controls.Add(td)
        td = New TableCell
        td.Text = "MaxValue"
        td.ID = "tdMaxValue"
        tr.Controls.Add(td)
        td = New TableCell
        td.Text = "Description1"
        td.ID = "tdDescription1"
        tr.Controls.Add(td)
        td = New TableCell
        td.Text = "Description2"
        td.ID = "tdDescription2"
        tr.Controls.Add(td)
        td = New TableCell
        td.Text = "Currency"
        td.ID = "tdCurrency"
        tr.Controls.Add(td)
        td = New TableCell
        td.Text = "Scale Multiplier"
        td.ID = "tdScaleMultiplier"
        tr.Controls.Add(td)
        tb.Controls.Add(tr)
For i As Integer = 1 To ddlst_Scale_Type.SelectedValue
           buLabl = New Label
           buLabl.Text = "lbl" & i
           tr = New TableRow
           tr.ID = "trData_" & i
           td = New TableCell
           td.ID = "tdData_" & i & "0"
           td.Controls.Add(buLabl)
           tr.Controls.Add(td)
           pklst = New IMaCS.Framework.UI.ImacsListControls.PickList.PickListControl
           pklst = ScrObjects.createPKLIST_grid(PickList.PickListTypes.MST_CURRENCY, "pklstProduct" & (i), 100, "", "")
           Me.Controls.Add(pklst)
           td = New TableCell
           td.ID = "tdData_" & i & "1"
           td.Controls.Add(pklst)
           tr.Controls.Add(td)
           pklst = New IMaCS.Framework.UI.ImacsListControls.PickList.PickListControl
           pklst = ScrObjects.createPKLIST_grid(PickList.PickListTypes.MST_BUSINESS_UNIT, "pklstProcess" & (i), 100, "", "")
           td = New TableCell
           td.ID = "tdData_" & i & "2"
           td.Controls.Add(pklst)
           tr.Controls.Add(td)
           pklst = New IMaCS.Framework.UI.ImacsListControls.PickList.PickListControl
           pklst = ScrObjects.createPKLIST_grid(PickList.PickListTypes.MST_RISK_EVENT, "pklstRE" & (i), 100, "", "")
           td = New TableCell
           td.ID = "tdData_" & i & "3"
           td.Controls.Add(pklst)
           tr.Controls.Add(td)
           pklst = New IMaCS.Framework.UI.ImacsListControls.PickList.PickListControl
           pklst = ScrObjects.createPKLIST_grid(PickList.PickListTypes.MST_LOCATION, "pklstSC" & (i), 100, "", "")
           td = New TableCell
           td.ID = "tdData_" & i & "4"
           td.Controls.Add(pklst)
           tr.Controls.Add(td)
           tb.Controls.Add(tr)
       Next
 
       tr = New TableRow
       td = New TableCell
       td.ColumnSpan = 5
       buLabl = New Label
       buLabl.Text = " "
       td.Controls.Add(buLabl)
       td.BackColor = Drawing.Color.FromName("#c0c0c0")
       tr.Controls.Add(td)
       tb.Controls.Add(tr)
 
    End Sub
 

 
Me.Controls.Add(pklst)
 
here is the exception occured
Posted 5-Mar-13 2:05am
Edited 6-Mar-13 1:16am
v2
Comments
Tadit Dash at 5-Mar-13 7:26am
   
Have you debugged and checked where exactly you are getting this exception ?
If yes, then please mention which line of code exactly that is.
 
Otherwise we can't just go through this large code and assume what may be causing the problem.
Member 9410081 at 6-Mar-13 0:52am
   
Me.Controls.Add(pklst)
 
here is the exception occured
ryanb31 at 5-Mar-13 8:10am
   
The error tells you what is happening. If you are dynamically adding controls use the Pages OnInit event.
Member 9410081 at 6-Mar-13 0:53am
   
i am adding the controls dynamically ,
i am adding on dropdown selection.
how to resolve this
ryanb31 at 6-Mar-13 6:57am
   
You are adding more controls when the dropdown changes? Then I am not sure. Maybe you can preload the controls and then on dropdown change you can make them visible or not. Or possibly during OnInit you can check for IsPostback and then find which control caused the postback and if it is your dropdown then add the controls.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 6,055
1 DamithSL 4,621
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,500
4 Sergey Alexandrovich Kryukov 3,294


Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 6 Mar 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100