Setting Text Programmatically of a Databound TextBox

Today I want to share with you what I have discovered in setting a text or value in databound textbox in Visual Basic .NET. I almost spend a day figuring out how to do this. While the internet is my assistant all the time, sometimes it is inevitable that the information is outdated and we cannot find the correct answer as expected.

Scenario

You bound a TextBox using a DataSet and you want to change the value to something like an auto-generated key. While this can be done easily as we may think like the following code:

InvoiceTextBox.Text = "INV-0001"

But the above code will not turn your textbox into “INV-0001” as the new value.

If you are using a bound control like textbox the following code is the right answer:

InvoiceDataSet.Invoice.InvoiceNoColumn.DefaultValue = "INV-0001"

You need to call the name of the dataset followed by the table name and the field.

Dataset: InvoiceDataSet
Table: Invoice
Field: InvoiceNoColumn

Comments

Submitted byAnonymous (not verified)on Tue, 11/24/2009 - 14:08

Please let me know how to install sql server on win vista because when I install only creation of instance come and there is no window for sql manager... Pls Help

I supposed to displayed the Sales Details and get the Total Sales using 2 DatePickers(FromDate and ToDate) and Display details to datagrid and Total Sales to a Label Control..but,,,this error will came out everytime i clicked the command button: here's my code: If FromDate > ToDate Then MsgBox "From Date must be less than To Date." & vbCrLf & "Cannot display.!", vbExclamation, "FAILED" Exit Sub Else '***********this portion displays details to the datagrid ghost = "Select * from QrySalesDetails where DatePurchased >= '" & FromDate & "' and DatePurchased
Submitted byAnonymous (not verified)on Mon, 11/30/2009 - 14:03

In reply to by admin

the error on this Code..Datagrid3.Row = i
Submitted byadminon Wed, 12/02/2009 - 11:54

In reply to by Anonymous (not verified)

I'm wondering why you use DataGrid3.ApproxCount - 1 in this line: For i = 0 To DataGrid3.ApproxCount - 1 I think you need to use the recordcount of the Adodc and not he ApproxCount of DataGrid.
Submitted byAnonymous (not verified)on Wed, 12/02/2009 - 13:57

In reply to by admin

can u pls Correct that line of Code Sir.?can u give me a sample code to that,?
Submitted byAnonymous (not verified)on Sat, 11/28/2009 - 21:29

hi sir, ive been searching the site to find a similar program for our software engineering subject, im a junior student taking up BS in IT..so this is my problem..we're about to make a system and i just wanna ask your help if you have an idea about this... we proposed a health center automation system.. one of the key features of this is system is to notify the system administrator whenever a there is a scheduled patient. for example, if 10 patient has a schedule check up on friday, the system will notify the administrator about this 3 days before the schedule and ask him to remind the patients.if he wont check this reminders the system will still do the same thing the next day.. its okay if you wont teach me the whole code,i just need an idea..ive been studying vb 2008 express edition myself for 3 months no. please e-mail me: [email protected] THANKS in advance.

Add new comment