Hello,
I have to create data input forms to capture data (for sql server). I
was just wondering weather there is an automated way (like using the
datagrid) to link the "textbox.text" with the update command of the
data adapter ….
Many thanks in advance! 6 2144
Hi Saturnius,
A sample I once made, (when you do not have that date problems or other
conversions, you can skip that Mybinding and add the bindings direct as a
string to the databinding. And skip all other things. (It is thna one line
of code)
I hope this helps
Cor
\\\
Private Sub myroutine()
Mybinding = New Binding("Text", ds.Tables(0), "mydatfield")
textdatfield.DataBindings.Add(Mybinding)
AddHandler mybinding.Format, AddressOf DBdateTextbox
AddHandler mybinding.Parse, AddressOf TextBoxDBdate
End sub
Private Sub DBdateTextbox(ByVal sender As Object, _
ByVal cevent As ConvertEventArgs)
If cevent.Value Is DBNull.Value Then
cevent.Value = ""
Else
Dim datum As Date
cevent.Value = datum.ToString("dd - MM - yyyy")
End If
End Sub
Private Sub TextBoxDBdate(ByVal sender As Object, _
ByVal cevent As ConvertEventArgs)
If cevent.Value.ToString = "" Then
cevent.Value = DBNull.Value
End If
End Sub
//
Hello,
Thanks for the answer Cor (but this code is a bit to heavy for me ...)
I did something else:
- I can read the table names form the database
- I create Textboxes dynamic
- BUT how to read the data ....?????
Here goes the Code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
Try
Me.SqlConnection1.Open()
Dim cmd = New System.Data.SqlClient.SqlCommand("SELECT
* FROM myinformation", Me.SqlConnection1)
Dim Rd = cmd.ExecuteReader(CommandBehavior.SchemaOnly)
dt = (Rd.GetSchemaTable())
Rd.Close()
Me.SqlConnection1.Close()
Dim iCount As Integer = dt.Rows.Count - 1
Dim t As New Table
t.ID = "dyntab"
Dim i As Integer
Dim j As Integer
For i = 0 To iCount
Dim r As New TableRow
r.ID = "r" & i.ToString
Dim c As New TableCell
c.ID = "c" & i.ToString
c.Text = dt.Rows(i).Item(0)
r.Cells.Add(c)
Dim tc As New TableCell
Dim tb As New TextBox
tc.Controls.Add(tb)
tc.ID = dt.Rows(i).Item(0)
r.Cells.Add(tc)
t.Rows.Add(r)
Next
Panel1.Controls.Add(t)
Catch ex As Exception
Label1.Text = ex.Source & "--" & ex.Message
End Try
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Label1.Text = Panel1.Controls.Count
'' How to get the value of the textbox back????
End Sub
Hello,
Thanks for the answer Cor (but this code is a bit to heavy for me ...)
I did something else:
- I can read the table names form the database
- I create Textboxes dynamic
- BUT how to read the data ....?????
Here goes the Code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
Try
Me.SqlConnection1.Open()
Dim cmd = New System.Data.SqlClient.SqlCommand("SELECT
* FROM myinformation", Me.SqlConnection1)
Dim Rd = cmd.ExecuteReader(CommandBehavior.SchemaOnly)
dt = (Rd.GetSchemaTable())
Rd.Close()
Me.SqlConnection1.Close()
Dim iCount As Integer = dt.Rows.Count - 1
Dim t As New Table
t.ID = "dyntab"
Dim i As Integer
Dim j As Integer
For i = 0 To iCount
Dim r As New TableRow
r.ID = "r" & i.ToString
Dim c As New TableCell
c.ID = "c" & i.ToString
c.Text = dt.Rows(i).Item(0)
r.Cells.Add(c)
Dim tc As New TableCell
Dim tb As New TextBox
tc.Controls.Add(tb)
tc.ID = dt.Rows(i).Item(0)
r.Cells.Add(tc)
t.Rows.Add(r)
Next
Panel1.Controls.Add(t)
Catch ex As Exception
Label1.Text = ex.Source & "--" & ex.Message
End Try
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Label1.Text = Panel1.Controls.Count
'' How to get the value of the textbox back????
End Sub
Hi Saturnius,
When you are posting to this newsgroup than the default form is a
windowforms, what I did sent you does not work on a webform.
Your question is easy to answer.
Dim a As String = Me.TextBox1.Text
I saw some small errors in your code, the one I saw I have tried to correct
I hope this helps,
Cor
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If Not Page.IsPostBack Then Try Me.SqlConnection1.Open()
Dim cmd as New System.Data.SqlClient.SqlCommand("SELECT
* FROM myinformation", Me.SqlConnection1)
Dim Rd as System.Data.SqlClient.SqlDatareader
Rd = cmd.ExecuteReader(CommandBehavior.SchemaOnly)
dt = Rd.GetSchemaTable() Rd.Close() Me.SqlConnection1.Close()
Dim iCount As Integer = dt.Rows.Count - 1
Dim t As New Table t.ID = "dyntab" Dim i As Integer Dim j As Integer
For i = 0 To iCount Dim r As New TableRow r.ID = "r" & i.ToString Dim c As New TableCell c.ID = "c" & i.ToString
c.Text = dt.Rows(i).Item(0).toString r.Cells.Add(c) Dim tc As New TableCell Dim tb As New TextBox tc.Controls.Add(tb)
tc.ID = dt.Rows(i).Item(0).toString r.Cells.Add(tc) t.Rows.Add(r) Next Panel1.Controls.Add(t) Catch ex As Exception Label1.Text = ex.Source & "--" & ex.Message End Try End If End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Label1.Text = Panel1.Controls.Count '' How to get the value of the textbox back???? End Sub
Hi Saturnius,
When you are posting to this newsgroup than the default form is a
windowforms, what I did sent you does not work on a webform.
Your question is easy to answer.
Dim a As String = Me.TextBox1.Text
I saw some small errors in your code, the one I saw I have tried to correct
I hope this helps,
Cor
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If Not Page.IsPostBack Then Try Me.SqlConnection1.Open()
Dim cmd as New System.Data.SqlClient.SqlCommand("SELECT
* FROM myinformation", Me.SqlConnection1)
Dim Rd as System.Data.SqlClient.SqlDatareader
Rd = cmd.ExecuteReader(CommandBehavior.SchemaOnly)
dt = Rd.GetSchemaTable() Rd.Close() Me.SqlConnection1.Close()
Dim iCount As Integer = dt.Rows.Count - 1
Dim t As New Table t.ID = "dyntab" Dim i As Integer Dim j As Integer
For i = 0 To iCount Dim r As New TableRow r.ID = "r" & i.ToString Dim c As New TableCell c.ID = "c" & i.ToString
c.Text = dt.Rows(i).Item(0).toString r.Cells.Add(c) Dim tc As New TableCell Dim tb As New TextBox tc.Controls.Add(tb)
tc.ID = dt.Rows(i).Item(0).toString r.Cells.Add(tc) t.Rows.Add(r) Next Panel1.Controls.Add(t) Catch ex As Exception Label1.Text = ex.Source & "--" & ex.Message End Try End If End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Label1.Text = Panel1.Controls.Count '' How to get the value of the textbox back???? End Sub
Hi,
I got the answer from another newsgroup:
1.Create with ID - tb1.Id = "ControlID"
2.Button Click Event - Request.Form("ControlID")
Cheers Saturnius ;-)
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Joe Black |
last post by:
Hi everyone,
I have a pesky little problem that is driving me nuts.
I'm trying to capture an image of a web page programmatically in a
background thread or process.
What I'd like to do is create...
|
by: BlackFireNova |
last post by:
I'm using Access 2003, on Windows XP Pro.
I have a subform which is launched from a command button on my main form. When this form opens, I have 2 fields which I have inserted VBA Code into to...
|
by: max |
last post by:
Hello,
I am a newbye, and I'm trying to write a simple application.
I have five tables with three columns; all tables are identical; I need to
change some data in the first table and let VB...
|
by: pampululu |
last post by:
hello, I try to use directx.capture in my web application, I use
visual studio web developper 2005 express with c# for code behind.
I can list the webcam available on computer, no probem,
my...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
| |
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,...
|
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: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |