.NET Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgramming.NET Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 20th, 2004, 10:05 PM
renita renita is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 1 renita User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy Problem Accessing Dynamically Created Control

Hi All,
I have some Problem Accessing dynamically created controls. Actually what I have to do is
I have to get different set of questiond based on the order type.
For example , OrderType A may have 5 questions . It can be a short text, Long Text or a multiple choice question and
OrderType B may have 3 questions of different Type.
I have to create different control(textbox, multi line textbox, radioButton) based on the que type.
I am adding all the controls to a table and the table to a placeholder.
I don't have any problem creating the questions and controls dynamically.
But the problem bubble up when i try to access the dynamically created control.
I am creating the control in the Page_Init
and I am trying to get the response from those dynamically created control once the user click on the submit button.
Here is the code:
PrivateSub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Init
Dim mytable AsNew Table
Dim que As DataTable
Dim qrow As DataRow
Dim row AsInteger
IfNot IsPostBack Then
Dim myorderid = CInt(1)
Dim myaccount As DNS.OrdersDB = New DNS.OrdersDB
myserviceid = myaccount.GetServiceType(myorderid)
que = New DataTable
que = DNS.QADB.GetQuestions(myserviceid).Tables(0)
row = CInt(que.Rows.Count)
Dim i AsInteger
For i = 0 To row - 1
qrow = que.Rows(i)
Dim mytype AsString = qrow("QueType")
Dim myreq AsString = qrow("QueRequired")
If mytype = "SHORT TEXT" Then
Dim myrow AsNew TableRow
Dim myrow1 AsNew TableRow
Dim mycell AsNew TableCell
Dim mycell1 AsNew TableCell
Dim lbl As Label = New Label
lbl.Text = qrow("QueName")
Dim mylblid AsString = "lbl" + CStr(qrow("Queid"))
lbl.ID = mylblid
Dim txt As TextBox = New TextBox
txt.ID = qrow("Queid").ToString()
txt.Width = Unit.Pixel(Convert.ToInt32(200).ToString())
mycell.Controls.Add(lbl)
mycell1.Controls.Add(txt)
myrow.Cells.Add(mycell)
myrow1.Cells.Add(mycell1)
mytable.Rows.Add(myrow)
mytable.Rows.Add(myrow1)
ElseIf (mytype = "LONG TEXT") Then
' as added above
End If
Next
myplace.Controls.Add(mytable)
EndIf
EndSub

Private Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
Dim mytable As New Table
Dim que As DataTable
Dim qrow As DataRow
Dim row As Integer
Dim myorderid = CInt(1)
Dim myaccount As DNS.OrdersDB = New DNS.OrdersDB
myserviceid = myaccount.GetServiceType(myorderid)
que = New DataTable
que = DNS.QADB.GetQuestions(myserviceid).Tables(0)
row = CInt(que.Rows.Count)
Dim i As Integer
For i = 0 To row - 1
qrow = que.Rows(i)
Dim mytype As String = qrow("QueType")
Dim myreq As String = qrow("QueRequired")
If mytype = "SHORT TEXT" Or mytype = "LONG TEXT" Then
' Trying to get the value of the textbox
Dim c As TextBox = Page.FindControl(qrow("QueId"))
Dim myresponse As String = c.Text
If myreq = "YES" And myresponse = "" Then
lblerr.Text = qrow("QueName")
lblerr.Visible = True
Else
Dim mysystem As DNS.QADB = New DNS.QADB
Dim mystsring As String = mysystem.addQAResponse(qrow("QueId"), myresponse)
End If
End If
Next
End Sub
It's really very urgent. Please someone help me with this. Any Help is greatly appreciated
Thanks

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgramming.NET Development > Problem Accessing Dynamically Created Control


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT