PC Review


Reply
Thread Tools Rate Thread

Questions about binding textboxes.

 
 
Aaron
Guest
Posts: n/a
 
      30th Jan 2004
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
 
Reply With Quote
 
 
 
 
Ken Tucker [MVP]
Guest
Posts: n/a
 
      30th Jan 2004
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
------------------
"Aaron" <(E-Mail Removed)> wrote in message
news:Xns94807F5F05276aaronjonharveycom1@216.77.188.18...
>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



 
Reply With Quote
 
 
 
 
Aaron
Guest
Posts: n/a
 
      30th Jan 2004
Thank you very much!


"Ken Tucker [MVP]" <(E-Mail Removed)> wrote in news:u0UoUm25DHA.2736
@TK2MSFTNGP09.phx.gbl:

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


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Design-Time Binding versus Run-Time Binding in VB.NET =?Utf-8?B?c29mdGVuZ2luZQ==?= Microsoft Dot NET 1 13th May 2005 09:10 AM
Late Binding examples of binding excel application =?Utf-8?B?SGVhdGhlck8=?= Microsoft Excel Programming 14 17th Mar 2005 09:19 AM
threading, what different between DataGrid Binding to Binding TextBox mttc Microsoft Dot NET Framework Forms 3 19th Nov 2004 09:33 AM
Re: Data Binding - using inline code vs. functions vs. straight binding Alvin Bruney [MVP] Microsoft ASP .NET 0 9th Mar 2004 02:24 PM
EARLY binding or LATE binding ? jason Microsoft Excel Programming 6 26th Feb 2004 05:57 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:05 PM.