Share Your Source Code or Article

Do you have source code, articles, tutorials, web links, and books to share? You can write your own content here. You can even have your own blog.

Submit now...

Database Programming Made Easy

This tutorial will teach you step by step on how to connect and manipulate database. If you'd like to suggest a tutorial please write a comment at the bottom of this article.

Read more...

Hire Us to Do Your Work

Do you want a customized system? Do you want to setup your own website to do business? Then we are here to help you in your programming needs.

Read more...

Search

Setting Text Programmatically of a Databound TextBox
admin's picture


0
Your rating: None
Language: 

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




PLEASE HELP

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: bien_zales@yahoo.com
THANKS in advance.

ghostEncryption's picture

Hi Sir.!

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 <='" & ToDate & "' "
Adodc2.RecordSource = ghost
Adodc2.Refresh
'**********this will be the computation for totalsales
Dim i As Integer
Dim TAmt As Currency
TAmt = 0
i = 0
DataGrid3.Col = 6
For i = 0 To DataGrid3.ApproxCount - 1
DataGrid3.Row = i
TAmt = TAmt + Val(DataGrid3.Columns(6).Text)
Next
Label3 = Format(TAmt, "##,##0.00")

End If
'************then, this will be the Error

Run-time error '6148': Invalid Row number

.......Pls help how to solve this problem,"need this urgent..,pls,"

ghostencryption

admin's picture

re: Hi Sir.!

On which line the error occurs?

hi

the error on this Code..Datagrid3.Row = i

admin's picture

re: hi

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.

Pls Help

can u pls Correct that line of Code Sir.?can u give me a sample code to that,?

SQL Server 2008

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

Post new comment

  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <java>, <java5>, <javascript>, <mysql>, <php>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • You may use [inline:xx] tags to display uploaded files or images inline.
  • Links to specified hosts will have a rel="nofollow" added to them.

  • You may insert videos with [video:URL]

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.

Step by Step Java Tutorial

In this tutorial you will learn how to program with Java. It has a rich of information to be educated well with Java.

Read more...

Do You Have Question?

Do you have any question related to computer programming? Visit our forum and post new topic on the category you like. Be gentle when asking a question.

Ask now...

Point of Sale

Point of Sale is very useful especially for supermarkets or restaurants. I have included a barcode scanner in this program. Please check it out.

Read more...