[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.4

Getting the value from controls created at runtime

Asked by nilesh_kshirsagar in Programming for ASP.NET

Tags: runtime

Hello,
I am creating  the form controls at runtime in my ASPX page on a button click event in a table designed at design time. The ID of Table is (tbl) . To this table I am adding the rows, cells and the controls called dropdownlist and a textbox in a cell at runtime.
When the user fills the values click for save button, I want to get the values from the dropdownlist saves into my database.

The code I wrote is as follows:
Private Sub btnADD_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnADD.Click
        Dim i As Short
        Dim row As TableRow
        Dim cell As TableCell
        Dim ddl As DropDownList
        Dim lst As ListBox

For i = 1 To TxtValue.Text
            row = New TableRow
            ' ADD FUNCTIONS
            ddl = New DropDownList
            ddl.ID = "function" & i
            ddl.DataTextField = "FLD_FUNCTION_DISPLAY_NAME"
            ddl.DataValueField = "FLD_FUNCTION_NAME"
            ddl.DataSource = objDS
            ddl.DataBind()

            cell = New TableCell
            cell.Controls.Add(ddl)
            row.Cells.Add(cell)

            ' ADD FIELD TEXT
            cell = New TableCell
            cell.Text = "FIELD" & i
            row.Cells.Add(cell)

            ' ADD RETURN TYPE
            cell = New TableCell
            lst = New ListBox
            lst.SelectionMode = ListSelectionMode.Single
            lst.Rows = 1
            lst.ID = "return" & i
            Dim lstItem As ListItem
            lstItem = New ListItem
            lstItem.Value = "1"
            lstItem.Text = "TRUE"
            lst.Items.Add(lstItem)
            lstItem = New ListItem
            lstItem.Value = "0"
            lstItem.Text = "FALSE"
            lst.Items.Add(lstItem)
            cell.Controls.Add(lst)
            row.Cells.Add(cell)

            ' ADD and / or
            cell = New TableCell
            If Not i = TxtValue.Text Then
                lst = New ListBox
                lst.SelectionMode = ListSelectionMode.Single
                lst.Rows = 1
                lst.ID = "andor" & i
                lst.Items.Add("AND")
                lst.Items.Add("OR")
                cell.Controls.Add(lst)
            End If
            row.Cells.Add(cell)

            tbl.Rows.Add(row)
        Next
End sub

Now I am retreiving the values inside a dropdownlist as follows:

Private Sub btnSAVE_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSAVE.Click

Dim lstBox As ListBox
For
For i = 1 To txtNumberOfRows.Text

lstBox = Page.FindControl("Form1").FindControl("tbl").FindControl("row" & i).FindControl("cell" & i).FindControl("lstreturn" & i)

Next
End sub

But I am getting the value of lstBox as nothing.

Will anyone give me the solution for this?

Looking for a kindly help.

Thank you

Nilesh



 
[+][-]02/24/05 01:19 AM, ID: 13390750Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: Programming for ASP.NET
Tags: runtime
Sign Up Now!
Solution Provided By: kaliyappan_k
Participating Experts: 1
Solution Grade: B
 
[+][-]03/20/05 07:49 AM, ID: 13586081Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-89