Questions about binding textboxes.

A

Aaron

I haveseveral textboxes which are being populated by clicking on a row in
a datagrid.

Dim CRI = DataGrid1.CurrentRowIndex.ToString
txtRegCode.Text() = DataGrid1.Item(CRI, 0)
txtFullname.Text() = DataGrid1.Item(CRI, 1)
txtTitle.Text() = DataGrid1.Item(CRI, 2)
txtCompany.Text() = DataGrid1.Item(CRI, 3)
txtNotes.Text() = DataGrid1.Item(CRI, 10)
txtConfNotes.Text() = DataGrid1.Item(CRI, 11)
txtActDate.Text() = DataGrid1.Item(CRI, 12)
txtFollowUpDate.Text() = DataGrid1.Item(CRI, 13)
txtACD.Text() = DataGrid1.Item(CRI, 14)
txtCompensation.Text() = DataGrid1.Item(CRI, 18)
txtAppSalary.Text() = DataGrid1.Item(CRI, 19)
txtBPhone.Text() = DataGrid1.Item(CRI, 4)
txtResume.Text() = DataGrid1.Item(CRI, 6)
txtphone.Text() = DataGrid1.Item(CRI, 16)
txtRCD.Text() = DataGrid1.Item(CRI, 15)
txtWorkExt.Text() = DataGrid1.Item(CRI, 5)
txtAppCell.Text() = DataGrid1.Item(CRI, 17)

As you can see, I am using the Datagrid.Item() method of poulating the
textboxes.

The problem I am having is when the record contains a null value, any
textboxes to be filled after the null cell is encountered fail to
populate. As a temporary workaround, I started moving the order in which
the textboxes are populated, moving those columns which most often have
null values to the end of the drawing order, but that still does not
correct the problem.

Is there anyway to handle the null value issue?

I tried:

if Datagrid1.Item(CRI, X) is dbnull.value
then Datagrid1.Item(CRI, X) = ""
end if

with no success.

If I knew how to bind the textboxes directly to the Dataset, then could I
handle this condition any easier? Does anyone know how to take this
approach?


Thanks,
Aaron
 
K

Ken Tucker [MVP]

Hi,

If you bind the textboxes to the same datasource as the datagrid
the currency manager will keep them in sync with the datagrid.

DataGrid1.DataSource = dv

TextBox1.DataBindings.Add("Text", dv, "CategoryName")



Ken
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top