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
Hi Sir.!
PLEASE HELP
Add new comment
- Add new comment
- 33 views