473,396 Members | 1,738 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How can i get place holder dynamic textbox values

Hi all,

i am using place holder for dynamic textbox and label box, then when i enter the values in textbox then i click the add button and save to database, but i couldnt get the dynamic textbox values, Pllssssssssss help how can i get the dynamic values using vb.net

pls help me as soon as possible
regards
kumar

thanxxx....
Aug 13 '08 #1
9 3998
Hey dear you have to use ViewState variable for your dynamic controls to keep their values save on postback
Aug 13 '08 #2
Hey dear you have to use ViewState variable for your dynamic controls to keep their values save on postback

thanx..

But i am new to vb.net
so i show my code then u will reply me how can i use viewstate

can u help me...
advance thanx...

Expand|Select|Wrap|Line Numbers
  1.  
  2.  Protected Sub BTN_FILTER_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BTN_FILTER.Click
  3.         Dim Hostelname, roomcategory, roomcode As String
  4.         Dim noofseats, totalroom As Integer
  5.         If drp_Hostelname.SelectedIndex = 0 Then
  6.             Hostelname = "%"
  7.         Else
  8.             Hostelname = drp_Hostelname.SelectedItem.Text
  9.         End If
  10.         If drp_Roomcategory.SelectedIndex = 0 Then
  11.             roomcategory = "%"
  12.         Else
  13.             roomcategory = drp_Roomcategory.SelectedItem.Text
  14.         End If
  15.  
  16.         sql_Connect.ConnectionString = System.Configuration.ConfigurationManager.AppSettings("ConString")
  17.         sql_cmd.CommandText = "SELECT noofseats,totalroom  FROM roomcategory where hostelname='" & Hostelname & "' and roomcategory='" & roomcategory & "'"
  18.         sql_cmd.Connection = sql_Connect
  19.         sql_Connect.Open()
  20.         Dim dr As SqlDataReader
  21.         dr = sql_cmd.ExecuteReader
  22.         dr.Read()
  23.         noofseats = dr(0)
  24.         totalroom = dr(1)
  25.         HOW_MANY = noofseats * totalroom
  26.         dr.Close()
  27.         sql_Connect.Close()
  28.  
  29.  
  30.  
  31.         sql_cmd.CommandText = "SELECT roomcode  FROM roommaster where hostelname='" & Hostelname & "' and roomcategory='" & roomcategory & "'"
  32.         sql_cmd.Connection = sql_Connect
  33.         sql_Connect.Open()
  34.         Dim dr1 As SqlDataReader
  35.         dr1 = sql_cmd.ExecuteReader
  36.         dr1.Read()
  37.         roomcode = dr1(0)
  38.         dr1.Close()
  39.         sql_Connect.Close()
  40.  
  41.         Session("count") = HOW_MANY
  42.         For i = 1 To HOW_MANY
  43.  
  44.             Dim lbl As New Label()
  45.             lbl.ID = "R" & roomcode + i.ToString()
  46.             lbl.Text = lbl.ID
  47.             lbl.CssClass = "aspnetmaker"
  48.             lbl.Width = 60%
  49.  
  50.             add.Controls.Add(lbl)
  51.             If jlbl = 10 Then
  52.                 add.Controls.Add(New LiteralControl("<br>"))
  53.                 jlbl = 0
  54.             End If
  55.  
  56.  
  57.             If jlbl = 0 Then
  58.                 Call newtxt()
  59.             End If
  60.             jlbl = jlbl + 1
  61.  
  62.         Next
  63.  
  64.         add.Controls.Add(New LiteralControl("<br>"))
  65.         For i1 As Integer = 1 To jlbl - 1
  66.  
  67.             Dim txt As New TextBox()
  68.             txt.ID = "txt" + i1.ToString()
  69.             txt.CssClass = "aspnetmaker"
  70.             txt.Text = txt.ID
  71.             txt.Width = 60%
  72.  
  73.             add.Controls.Add(txt)
  74.             txt.Text = ""
  75.         Next
  76.         add.Controls.Add(New LiteralControl("<br>"))
  77.         Dim btn As New Button
  78.         btn.Text = "Save"
  79.         btn.ID = "Btn_Save"
  80.         btn.Attributes("OnClick") = "__doPostBack('" + btn.ID + "'); "
  81.         'AddHandler Me.add.btn.Click, AddressOf btn_Click
  82.         add.Controls.Add(btn)
  83.     End Sub
  84.     Sub newtxt()
  85.         jtxt = 1
  86.         For i1 As Integer = 1 To i
  87.  
  88.             Dim txt As New TextBox()
  89.             txt.ID = "txt" + i1.ToString()
  90.  
  91.             txt.CssClass = "aspnetmaker"
  92.  
  93.             txt.Width = 60%
  94.  
  95.             add.Controls.Add(txt)
  96.  
  97.             If jtxt = 10 Then
  98.                 add.Controls.Add(New LiteralControl("<br>"))
  99.                 jtxt = 0
  100.             End If
  101.  
  102.             If jtxt = 0 Then
  103.                 Exit Sub
  104.             End If
  105.             jtxt = jtxt + 1
  106.         Next
  107.  
  108.  
  109.     End Sub
  110.  
  111.     Protected Sub btn_Save_Click(ByVal sender As Object, ByVal e As System.EventArgs)
  112.  HOW_MANY = Session("count")
  113.         For i As Integer = 0 To HOW_MANY - 1
  114.             Dim txtCtrl As String = "txt" + (i + 1).ToString
  115.             Dim currentControl As Control = Me.FindControl(txtCtrl)
  116.             If TypeOf currentControl Is TextBox Then     '
  117.                 Dim textBoxRef As TextBox = CType(currentControl, TextBox)
  118.  
  119.                 Me.Response.Write((txtCtrl + ": " + textBoxRef.Text + "<br>"))
  120.             End If
  121.         Next
  122.  
  123.  
  124.     End Sub
Aug 13 '08 #3
Curtis Rutland
3,256 Expert 2GB
Please use the CODE tags when posting code (the # button on the text editor). Especially when you are going to dump 120 lines of code on us.

MODERATOR
Aug 13 '08 #4
use
Expand|Select|Wrap|Line Numbers
  1. ViewState["USERCONTROLNAME"]= anyinstance;
only one in the code
and re create all the dynamic control on every post back


Hi all,

i am using place holder for dynamic textbox and label box, then when i enter the values in textbox then i click the add button and save to database, but i couldnt get the dynamic textbox values, Pllssssssssss help how can i get the dynamic values using vb.net

pls help me as soon as possible
regards
kumar

thanxxx....
Aug 13 '08 #5
Frinavale
9,735 Expert Mod 8TB
Hi all,

i am using place holder for dynamic textbox and label box, then when i enter the values in textbox then i click the add button and save to database, but i couldnt get the dynamic textbox values, Pllssssssssss help how can i get the dynamic values using vb.net

pls help me as soon as possible
regards
kumar

thanxxx....
Check out how to use dynamic controls in asp.net.

-Frinny
Aug 13 '08 #6
use
Expand|Select|Wrap|Line Numbers
  1. ViewState["USERCONTROLNAME"]= anyinstance;
only one in the code
and re create all the dynamic control on every post back

Hi thanx for ur reply,

My requirement is i am getting some values via dropdownlist then create x number of Labels and Text boxes when i am clicking a button. Then i put some values in the textboxes after that i have to show in a label all of the text box values. I am using viewstate but i couldnt get the values... can u help me immediatly for last 4 days i am trying but i couldn't finish..

if i create this code in page init and using view state i can get the values, but i cant use my code in page init because i have to take some values via ddropdownlist then show the textboxes by button clicking event thats why i havent get the view state values i think....

expect your reply..... as soon as possible..
Advance thanx....
Aug 18 '08 #7
Check out how to use dynamic controls in asp.net.

-Frinny
Hi

My requirement is i am getting some values via dropdownlist then create x number of Labels and Text boxes when i am clicking a button. Then i put some values in the textboxes after that i have to show in a label all of the text box values. I am using viewstate but i couldnt get the values... can u help me immediatly for last 4 days i am trying but i couldn't finish..

if i create this code in page init and using view state i can get the values, but i cant use my code in page init because i have to take some values via ddropdownlist then show the textboxes by button clicking event thats why i havent get the view state values i think....

expect your reply..... as soon as possible..
Advance thanx....
Aug 18 '08 #8
Check out how to use dynamic controls in asp.net.

-Frinny
Hi

My requirement is i am getting some values via dropdownlist then create x number of Labels and Text boxes when i am clicking a button. Then i put some values in the textboxes after that i have to show in a label all of the text box values. I am using viewstate but i couldnt get the values... can u help me immediatly for last 4 days i am trying but i couldn't finish..

if i create this code in page init and using view state i can get the values, but i cant use my code in page init because i have to take some values via ddropdownlist then show the textboxes by button clicking event thats why i havent get the view state values i think....

expect your reply..... as soon as possible..
Advance thanx....
Aug 18 '08 #9
Frinavale
9,735 Expert Mod 8TB
You want to declare your textboxes and labels so that they are global variables for the aspx page. You then want to instantiate these variables in your page_init event. After that point you should be able to access them anywhere in your aspx page.

Please post what you have tried so far.
Sep 5 '08 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Mark | last post by:
I want to create textboxes dynamically but with dynamic names also. i am retrieveing a load of values from a table in SQL into a DataReader. Then i want to create textboxes from those variables. ...
3
by: vitaly.tomilov | last post by:
I'm using an ASP.NET form to display data from my database table, and I'm doing it in the following way: XmlDataDocument doc = new XmlDataDocument(mydataSet); XPathNavigator nav =...
2
by: J-T | last post by:
I am constructing an HTML text which I need to render in my ASP.NET page. string rssOutput = Posts.listPosts(Constants.WeblogSectionID); rssOutput contains html code and text.Then I create a...
0
by: MasterChief | last post by:
I have a content place holder that is showing the summary of a sale. Is there a way to create a button in the content place holder that the person can click on to print just what is in the content...
1
by: lamuerte451 | last post by:
Hi: I am a newbie to asp.net 2.0 and am building an app with VS 2005 that will allow users to update records via the web. I have created a master page and then have placed Gridview and details...
4
Frinavale
by: Frinavale | last post by:
Introduction Sometimes, when developing web applications, we need to be able to dynamically load controls based on user selections. The following article describes a simple scenario where TextBox...
2
by: englishman69 | last post by:
Hello, I have been banging my head against this one for a while... Searches online have revealed many different proposals for correcting my issue but none that I can follow! My basic situation...
4
by: =?Utf-8?B?RHlsYW5TbWl0aA==?= | last post by:
I have a WebForm where I'm dynamically creating some controls and I'm having difficulty understanding how the state is being persisted and how to work with it. I've created a simplified example...
2
by: greenMark | last post by:
Hi All, I'm relatively new to ASP.NET and Visual Web Developer 2008. I'm using a Master page with one content place holder. There is a Cascading Style Sheet file which is being refered by the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.