Thursday, April 21, 2011

Create and Use Controls Dynamically in VB.NET

How to create and use Controls Dynamically in VB.NET:

Example code below is showing how you can create Controls dynamically and on save button click extracting values of fields and save back in database:

control.aspx page for Dynamica Control Form:



VB.NET Code is given below for dynamic form:





The above example Code Snaps are showing an easy way to create dynamic control and call dynamically created controls one by one during save (button click) to get values inserted by user.
The above code is using some static methods to distinguish for a field “date” in code like
If (j = 3) Then
sql &= "TO_DATE('" & txt.Text & "','DD/MM/YYYY')"
Else

End If

Reader can implement their own methods to distinguish different data field type Like Date, Time, email etc.

No comments:

Post a Comment