all groups > dotnet compact framework > february 2005 >
You're in the dotnet compact framework group:
Databinding Exception
dotnet compact framework:
hi guys i got a very strange problem here. In my program, i create the databinding between some textboxes ,comoboxes and a dataview. first i clear the databinding then add the databinding again. then i changed the current row in the dataview several times, the nullreferenceexception occurs.. really dont why any suggestion? cheeers victor
Most common reason for that problem is using control/binding row index as a row index in DataTable. Make sure you don't do that, use control/binding row index on DataView controls are bound to instead. Best regards, Ilya This posting is provided "AS IS" with no warranties, and confers no rights. -------------------- [quoted text, click to view] > From: "victor" <gshi@ebreathe.co.nz> > Subject: Databinding Exception > Date: Fri, 25 Feb 2005 17:21:16 +1300 > Lines: 13 > X-Priority: 3 > X-MSMail-Priority: Normal > X-Newsreader: Microsoft Outlook Express 6.00.2900.2527 > X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 > X-RFC2646: Format=Flowed; Original > Message-ID: <ucfR1FvGFHA.2360@TK2MSFTNGP12.phx.gbl> > Newsgroups: microsoft.public.dotnet.framework.compactframework > NNTP-Posting-Host: 203.97.94.50 > Path:
TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl!TK2MSFTNGP 08.phx.gbl!TK2MSFTNGP12.phx.gbl [quoted text, click to view] > Xref: TK2MSFTNGXA02.phx.gbl microsoft.public.dotnet.framework.compactframework:71883 > X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework > > hi guys > i got a very strange problem here. In my program, i create the databinding > between some textboxes ,comoboxes and a dataview. first i clear the > databinding then add the databinding again. then i changed the current row > in the dataview several times, the nullreferenceexception occurs.. really > dont why > any suggestion? > cheeers > victor > > > > >
I see nothing wrong with this code fragment, but since it's not your entire application, problem might be somewhere else. Make sure you do not delete/modify rows from/in the DataTable directly, only from/in DataView. Also make sure DataTable is not modified from other threads. Or come up with a repro (small, complete and compliable code) and post it to the NG so I can investigate. Best regards, Ilya This posting is provided "AS IS" with no warranties, and confers no rights. -------------------- [quoted text, click to view] > From: "Victor" <gang_shi@hotmail.com> > References: <ucfR1FvGFHA.2360@TK2MSFTNGP12.phx.gbl> <Yd#vrx2GFHA.1136@TK2MSFTNGXA02.phx.gbl> > Subject: Re: Databinding Exception > Date: Sat, 26 Feb 2005 20:41:12 +1300 > Lines: 104 > X-Priority: 3 > X-MSMail-Priority: Normal > X-Newsreader: Microsoft Outlook Express 6.00.2900.2527 > X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 > X-RFC2646: Format=Flowed; Original > Message-ID: <e7CJNa9GFHA.3076@tk2msftngp13.phx.gbl> > Newsgroups: microsoft.public.dotnet.framework.compactframework > NNTP-Posting-Host: 222-152-67-63.jetstream.xtra.co.nz 222.152.67.63 > Path:
TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp1 3.phx.gbl [quoted text, click to view] > Xref: TK2MSFTNGXA02.phx.gbl microsoft.public.dotnet.framework.compactframework:71954 > X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework > > Hi Ilya > thanks for the reply. but i still get some confusion here. what do you mean > using control/binding row index as i row index in DataTable? > In my program. i write something like > > public void AddDataBinding() > { >
this.cboCustomerName.DataBindings.Add("SelectedValue",this.dvCall,"CustomerC ode"); [quoted text, click to view] >
this.dpScheduleStartTime.DataBindings.Add("Value",this.dvCall,"ScheduleStart ed"); [quoted text, click to view] >
this.dpScheduleEndTime.DataBindings.Add("Value",this.dvCall,"ScheduleEnded") ; [quoted text, click to view] > >
this.txtAcutalStartTime.DataBindings.Add("Text",this.dvCall,"ActualStarted") ; [quoted text, click to view] > this.txtAcutalEndTime.DataBindings.Add("Text",this.dvCall,"ActualEnded"); > >
this.cboCallStatus.DataBindings.Add("SelectedValue",this.dvCall,"CallStatusI D"); [quoted text, click to view] > > } > > public void ClearDataBinding() > { > this.cboCustomerName.DataBindings.Clear(); > this.dpScheduleStartTime.DataBindings.Clear(); > this.dpScheduleEndTime.DataBindings.Clear(); > this.cboCallStatus.DataBindings.Clear(); > this.txtAcutalStartTime.DataBindings.Clear(); > } > > Did I do the right thing here? > Am i using the control/binding row index on DataView controls? > > cheers > victor > > > > > > > > > > > > > > > > > > > > ""Ilya Tumanov [MS]"" <ilyatum@online.microsoft.com> wrote in message > news:Yd%23vrx2GFHA.1136@TK2MSFTNGXA02.phx.gbl... > > Most common reason for that problem is using control/binding row index as > > a > > row index in DataTable. > > Make sure you don't do that, use control/binding row index on DataView > > controls are bound to instead. > > > > Best regards, > > > > Ilya > > > > This posting is provided "AS IS" with no warranties, and confers no > > rights. > > -------------------- > >> From: "victor" <gshi@ebreathe.co.nz> > >> Subject: Databinding Exception > >> Date: Fri, 25 Feb 2005 17:21:16 +1300 > >> Lines: 13 > >> X-Priority: 3 > >> X-MSMail-Priority: Normal > >> X-Newsreader: Microsoft Outlook Express 6.00.2900.2527 > >> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 > >> X-RFC2646: Format=Flowed; Original > >> Message-ID: <ucfR1FvGFHA.2360@TK2MSFTNGP12.phx.gbl> > >> Newsgroups: microsoft.public.dotnet.framework.compactframework > >> NNTP-Posting-Host: 203.97.94.50 > >> Path: > > TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl!TK2MSFTNGP > > 08.phx.gbl!TK2MSFTNGP12.phx.gbl > >> Xref: TK2MSFTNGXA02.phx.gbl > > microsoft.public.dotnet.framework.compactframework:71883 > >> X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework > >> > >> hi guys > >> i got a very strange problem here. In my program, i create the > >> databinding > >> between some textboxes ,comoboxes and a dataview. first i clear the > >> databinding then add the databinding again. then i changed the current > >> row > >> in the dataview several times, the nullreferenceexception occurs.. really > >> dont why > >> any suggestion? > >> cheeers > >> victor > >> > >> > >> > >> > >> > > > > >
Hi Ilya thanks for the reply. but i still get some confusion here. what do you mean using control/binding row index as i row index in DataTable? In my program. i write something like public void AddDataBinding() { this.cboCustomerName.DataBindings.Add("SelectedValue",this.dvCall,"CustomerCode"); this.dpScheduleStartTime.DataBindings.Add("Value",this.dvCall,"ScheduleStarted"); this.dpScheduleEndTime.DataBindings.Add("Value",this.dvCall,"ScheduleEnded"); this.txtAcutalStartTime.DataBindings.Add("Text",this.dvCall,"ActualStarted"); this.txtAcutalEndTime.DataBindings.Add("Text",this.dvCall,"ActualEnded"); this.cboCallStatus.DataBindings.Add("SelectedValue",this.dvCall,"CallStatusID"); } public void ClearDataBinding() { this.cboCustomerName.DataBindings.Clear(); this.dpScheduleStartTime.DataBindings.Clear(); this.dpScheduleEndTime.DataBindings.Clear(); this.cboCallStatus.DataBindings.Clear(); this.txtAcutalStartTime.DataBindings.Clear(); } Did I do the right thing here? Am i using the control/binding row index on DataView controls? cheers victor [quoted text, click to view] ""Ilya Tumanov [MS]"" <ilyatum@online.microsoft.com> wrote in message news:Yd%23vrx2GFHA.1136@TK2MSFTNGXA02.phx.gbl... > Most common reason for that problem is using control/binding row index as > a > row index in DataTable. > Make sure you don't do that, use control/binding row index on DataView > controls are bound to instead. > > Best regards, > > Ilya > > This posting is provided "AS IS" with no warranties, and confers no > rights. > -------------------- >> From: "victor" <gshi@ebreathe.co.nz> >> Subject: Databinding Exception >> Date: Fri, 25 Feb 2005 17:21:16 +1300 >> Lines: 13 >> X-Priority: 3 >> X-MSMail-Priority: Normal >> X-Newsreader: Microsoft Outlook Express 6.00.2900.2527 >> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 >> X-RFC2646: Format=Flowed; Original >> Message-ID: <ucfR1FvGFHA.2360@TK2MSFTNGP12.phx.gbl> >> Newsgroups: microsoft.public.dotnet.framework.compactframework >> NNTP-Posting-Host: 203.97.94.50 >> Path: > TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl!TK2MSFTNGP > 08.phx.gbl!TK2MSFTNGP12.phx.gbl >> Xref: TK2MSFTNGXA02.phx.gbl > microsoft.public.dotnet.framework.compactframework:71883 >> X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework >> >> hi guys >> i got a very strange problem here. In my program, i create the >> databinding >> between some textboxes ,comoboxes and a dataview. first i clear the >> databinding then add the databinding again. then i changed the current >> row >> in the dataview several times, the nullreferenceexception occurs.. really >> dont why >> any suggestion? >> cheeers >> victor >> >> >> >> >> >
That's a known bug in DataGrid discussed just recently. As a workaround, add data to the DataTable directly. To do it safely, create empty row, set all columns and add it to the table. Or, better yet, use DataTable.Rows.Add() overload with array of objects to set. Do not set columns after row has been added. I know it's confusing, sorry about that. This problem is fixed in CF V2. Best regards, Ilya This posting is provided "AS IS" with no warranties, and confers no rights. -------------------- [quoted text, click to view] > From: "Victor" <gang_shi@hotmail.com> > References: <ucfR1FvGFHA.2360@TK2MSFTNGP12.phx.gbl>
<Yd#vrx2GFHA.1136@TK2MSFTNGXA02.phx.gbl> <e7CJNa9GFHA.3076@tk2msftngp13.phx.gbl> <se6wTQDHFHA.1140@TK2MSFTNGXA02.phx.gbl> [quoted text, click to view] > Subject: Re: Databinding Exception > Date: Sun, 27 Feb 2005 22:31:53 +1300 > Lines: 171 > X-Priority: 3 > X-MSMail-Priority: Normal > X-Newsreader: Microsoft Outlook Express 6.00.2900.2527 > X-RFC2646: Format=Flowed; Original > X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 > Message-ID: <OeIz3ELHFHA.1096@tk2msftngp13.phx.gbl> > Newsgroups: microsoft.public.dotnet.framework.compactframework > NNTP-Posting-Host: 222-152-67-63.jetstream.xtra.co.nz 222.152.67.63 > Path:
TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp1 3.phx.gbl [quoted text, click to view] > Xref: TK2MSFTNGXA02.phx.gbl microsoft.public.dotnet.framework.compactframework:71983 > X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework > > hi Ilya > i found my problem is modify the underlying the datatable directly... > but i get a new problem there... after i new dataview.addnew() method.. i > get a indexofrangeexception in the datagrid.. > > can you help me out? > thank you > victor > > ""Ilya Tumanov [MS]"" <ilyatum@online.microsoft.com> wrote in message > news:se6wTQDHFHA.1140@TK2MSFTNGXA02.phx.gbl... > >I see nothing wrong with this code fragment, but since it's not your entire > > application, problem might be somewhere else. > > Make sure you do not delete/modify rows from/in the DataTable directly, > > only from/in DataView. > > Also make sure DataTable is not modified from other threads. > > > > Or come up with a repro (small, complete and compliable code) and post it > > to the NG so I can investigate. > > > > Best regards, > > > > Ilya > > > > This posting is provided "AS IS" with no warranties, and confers no > > rights. > > -------------------- > >> From: "Victor" <gang_shi@hotmail.com> > >> References: <ucfR1FvGFHA.2360@TK2MSFTNGP12.phx.gbl> > > <Yd#vrx2GFHA.1136@TK2MSFTNGXA02.phx.gbl> > >> Subject: Re: Databinding Exception > >> Date: Sat, 26 Feb 2005 20:41:12 +1300 > >> Lines: 104 > >> X-Priority: 3 > >> X-MSMail-Priority: Normal > >> X-Newsreader: Microsoft Outlook Express 6.00.2900.2527 > >> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 > >> X-RFC2646: Format=Flowed; Original > >> Message-ID: <e7CJNa9GFHA.3076@tk2msftngp13.phx.gbl> > >> Newsgroups: microsoft.public.dotnet.framework.compactframework > >> NNTP-Posting-Host: 222-152-67-63.jetstream.xtra.co.nz 222.152.67.63 > >> Path: > > TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp1 > > 3.phx.gbl > >> Xref: TK2MSFTNGXA02.phx.gbl > > microsoft.public.dotnet.framework.compactframework:71954 > >> X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework > >> > >> Hi Ilya > >> thanks for the reply. but i still get some confusion here. what do you > > mean > >> using control/binding row index as i row index in DataTable? > >> In my program. i write something like > >> > >> public void AddDataBinding() > >> { > >> > > this.cboCustomerName.DataBindings.Add("SelectedValue",this.dvCall,"CustomerC > > ode"); > >> > > this.dpScheduleStartTime.DataBindings.Add("Value",this.dvCall,"ScheduleStart > > ed"); > >> > > this.dpScheduleEndTime.DataBindings.Add("Value",this.dvCall,"ScheduleEnded") > > ; > >> > >> > > this.txtAcutalStartTime.DataBindings.Add("Text",this.dvCall,"ActualStarted") > > ; > >> > > this.txtAcutalEndTime.DataBindings.Add("Text",this.dvCall,"ActualEnded"); > >> > >> > > this.cboCallStatus.DataBindings.Add("SelectedValue",this.dvCall,"CallStatusI > > D"); > >> > >> } > >> > >> public void ClearDataBinding() > >> { > >> this.cboCustomerName.DataBindings.Clear(); > >> this.dpScheduleStartTime.DataBindings.Clear(); > >> this.dpScheduleEndTime.DataBindings.Clear(); > >> this.cboCallStatus.DataBindings.Clear(); > >> this.txtAcutalStartTime.DataBindings.Clear(); > >> } > >> > >> Did I do the right thing here? > >> Am i using the control/binding row index on DataView controls? > >> > >> cheers > >> victor > >> > >> > >> > >> > >> > >> > >> > >> > >> > >> > >> > >> > >> > >> > >> > >> > >> > >> > >> > >> ""Ilya Tumanov [MS]"" <ilyatum@online.microsoft.com> wrote in message > >> news:Yd%23vrx2GFHA.1136@TK2MSFTNGXA02.phx.gbl... > >> > Most common reason for that problem is using control/binding row index > > as > >> > a > >> > row index in DataTable. > >> > Make sure you don't do that, use control/binding row index on DataView > >> > controls are bound to instead. > >> > > >> > Best regards, > >> > > >> > Ilya > >> > > >> > This posting is provided "AS IS" with no warranties, and confers no > >> > rights. > >> > -------------------- > >> >> From: "victor" <gshi@ebreathe.co.nz> > >> >> Subject: Databinding Exception > >> >> Date: Fri, 25 Feb 2005 17:21:16 +1300 > >> >> Lines: 13 > >> >> X-Priority: 3 > >> >> X-MSMail-Priority: Normal > >> >> X-Newsreader: Microsoft Outlook Express 6.00.2900.2527 > >> >> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 > >> >> X-RFC2646: Format=Flowed; Original > >> >> Message-ID: <ucfR1FvGFHA.2360@TK2MSFTNGP12.phx.gbl> > >> >> Newsgroups: microsoft.public.dotnet.framework.compactframework > >> >> NNTP-Posting-Host: 203.97.94.50 > >> >> Path: > >> > > > TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl!TK2MSFTNGP > >> > 08.phx.gbl!TK2MSFTNGP12.phx.gbl > >> >> Xref: TK2MSFTNGXA02.phx.gbl > >> > microsoft.public.dotnet.framework.compactframework:71883 > >> >> X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework > >> >> > >> >> hi guys > >> >> i got a very strange problem here. In my program, i create the > >> >> databinding > >> >> between some textboxes ,comoboxes and a dataview. first i clear the > >> >> databinding then add the databinding again. then i changed the current > >> >> row > >> >> in the dataview several times, the nullreferenceexception occurs.. > > really > >> >> dont why > >> >> any suggestion? > >> >> cheeers > >> >> victor > >> >> > >> >> > >> >> > >> >> > >> >> > >> > > >> > >> > >> > > > > >
That would work, but it's slower as grid would rebind every time you're adding a row. If performance is acceptable, you sure can do it this way. Best regards, Ilya This posting is provided "AS IS" with no warranties, and confers no rights. -------------------- [quoted text, click to view] > From: "victor" <gshi@ebreathe.co.nz> > References: <ucfR1FvGFHA.2360@TK2MSFTNGP12.phx.gbl>
<Yd#vrx2GFHA.1136@TK2MSFTNGXA02.phx.gbl> <e7CJNa9GFHA.3076@tk2msftngp13.phx.gbl> <se6wTQDHFHA.1140@TK2MSFTNGXA02.phx.gbl> <OeIz3ELHFHA.1096@tk2msftngp13.phx.gbl> <tfg1PoPHFHA.1140@TK2MSFTNGXA02.phx.gbl> [quoted text, click to view] > Subject: Re: Databinding Exception > Date: Mon, 28 Feb 2005 09:41:50 +1300 > Lines: 240 > X-Priority: 3 > X-MSMail-Priority: Normal > X-Newsreader: Microsoft Outlook Express 6.00.2900.2527 > X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 > X-RFC2646: Format=Flowed; Original > Message-ID: <OE$sEzQHFHA.2616@tk2msftngp13.phx.gbl> > Newsgroups: microsoft.public.dotnet.framework.compactframework > NNTP-Posting-Host: 203.97.94.50 > Path:
TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp1 3.phx.gbl [quoted text, click to view] > Xref: TK2MSFTNGXA02.phx.gbl microsoft.public.dotnet.framework.compactframework:72001 > X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework > > hi Ilya.. > I found another way to do this, but I am not sure it is the current one. > before I use dataview.addnew() , i set the datagrid.datasource = null.. then > i call addnew() and set the value to each column.. at last i set the > datagrid.datasource = dataview again.. seems the problem fixed.. is that a > possible way? > cheers > victor > > > ""Ilya Tumanov [MS]"" <ilyatum@online.microsoft.com> wrote in message > news:tfg1PoPHFHA.1140@TK2MSFTNGXA02.phx.gbl... > > That's a known bug in DataGrid discussed just recently. > > As a workaround, add data to the DataTable directly. > > To do it safely, create empty row, set all columns and add it to the > > table. > > Or, better yet, use DataTable.Rows.Add() overload with array of objects to > > set. > > Do not set columns after row has been added. > > I know it's confusing, sorry about that. This problem is fixed in CF V2. > > > > Best regards, > > > > Ilya > > > > This posting is provided "AS IS" with no warranties, and confers no > > rights. > > > > -------------------- > >> From: "Victor" <gang_shi@hotmail.com> > >> References: <ucfR1FvGFHA.2360@TK2MSFTNGP12.phx.gbl> > > <Yd#vrx2GFHA.1136@TK2MSFTNGXA02.phx.gbl> > > <e7CJNa9GFHA.3076@tk2msftngp13.phx.gbl> > > <se6wTQDHFHA.1140@TK2MSFTNGXA02.phx.gbl> > >> Subject: Re: Databinding Exception > >> Date: Sun, 27 Feb 2005 22:31:53 +1300 > >> Lines: 171 > >> X-Priority: 3 > >> X-MSMail-Priority: Normal > >> X-Newsreader: Microsoft Outlook Express 6.00.2900.2527 > >> X-RFC2646: Format=Flowed; Original > >> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 > >> Message-ID: <OeIz3ELHFHA.1096@tk2msftngp13.phx.gbl> > >> Newsgroups: microsoft.public.dotnet.framework.compactframework > >> NNTP-Posting-Host: 222-152-67-63.jetstream.xtra.co.nz 222.152.67.63 > >> Path: > > TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp1 > > 3.phx.gbl > >> Xref: TK2MSFTNGXA02.phx.gbl > > microsoft.public.dotnet.framework.compactframework:71983 > >> X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework > >> > >> hi Ilya > >> i found my problem is modify the underlying the datatable directly... > >> but i get a new problem there... after i new dataview.addnew() method.. i > >> get a indexofrangeexception in the datagrid.. > >> > >> can you help me out? > >> thank you > >> victor > >> > >> ""Ilya Tumanov [MS]"" <ilyatum@online.microsoft.com> wrote in message > >> news:se6wTQDHFHA.1140@TK2MSFTNGXA02.phx.gbl... > >> >I see nothing wrong with this code fragment, but since it's not your > > entire > >> > application, problem might be somewhere else. > >> > Make sure you do not delete/modify rows from/in the DataTable directly, > >> > only from/in DataView. > >> > Also make sure DataTable is not modified from other threads. > >> > > >> > Or come up with a repro (small, complete and compliable code) and post > > it > >> > to the NG so I can investigate. > >> > > >> > Best regards, > >> > > >> > Ilya > >> > > >> > This posting is provided "AS IS" with no warranties, and confers no > >> > rights. > >> > -------------------- > >> >> From: "Victor" <gang_shi@hotmail.com> > >> >> References: <ucfR1FvGFHA.2360@TK2MSFTNGP12.phx.gbl> > >> > <Yd#vrx2GFHA.1136@TK2MSFTNGXA02.phx.gbl> > >> >> Subject: Re: Databinding Exception > >> >> Date: Sat, 26 Feb 2005 20:41:12 +1300 > >> >> Lines: 104 > >> >> X-Priority: 3 > >> >> X-MSMail-Priority: Normal > >> >> X-Newsreader: Microsoft Outlook Express 6.00.2900.2527 > >> >> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 > >> >> X-RFC2646: Format=Flowed; Original > >> >> Message-ID: <e7CJNa9GFHA.3076@tk2msftngp13.phx.gbl> > >> >> Newsgroups: microsoft.public.dotnet.framework.compactframework > >> >> NNTP-Posting-Host: 222-152-67-63.jetstream.xtra.co.nz 222.152.67.63 > >> >> Path: > >> > > > TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp1 > >> > 3.phx.gbl > >> >> Xref: TK2MSFTNGXA02.phx.gbl > >> > microsoft.public.dotnet.framework.compactframework:71954 > >> >> X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework > >> >> > >> >> Hi Ilya > >> >> thanks for the reply. but i still get some confusion here. what do you > >> > mean > >> >> using control/binding row index as i row index in DataTable? > >> >> In my program. i write something like > >> >> > >> >> public void AddDataBinding() > >> >> { > >> >> > >> > > > this.cboCustomerName.DataBindings.Add("SelectedValue",this.dvCall,"CustomerC > >> > ode"); > >> >> > >> > > > this.dpScheduleStartTime.DataBindings.Add("Value",this.dvCall,"ScheduleStart > >> > ed"); > >> >> > >> > > > this.dpScheduleEndTime.DataBindings.Add("Value",this.dvCall,"ScheduleEnded") > >> > ; > >> >> > >> >> > >> > > > this.txtAcutalStartTime.DataBindings.Add("Text",this.dvCall,"ActualStarted") > >> > ; > >> >> > >> > > > this.txtAcutalEndTime.DataBindings.Add("Text",this.dvCall,"ActualEnded"); > >> >> > >> >> > >> > > > this.cboCallStatus.DataBindings.Add("SelectedValue",this.dvCall,"CallStatusI > >> > D"); > >> >> > >> >> } > >> >> > >> >> public void ClearDataBinding() > >> >> { > >> >> this.cboCustomerName.DataBindings.Clear(); > >> >> this.dpScheduleStartTime.DataBindings.Clear(); > >> >> this.dpScheduleEndTime.DataBindings.Clear(); > >> >> this.cboCallStatus.DataBindings.Clear(); > >> >> this.txtAcutalStartTime.DataBindings.Clear(); > >> >> } > >> >> > >> >> Did I do the right thing here? > >> >> Am i using the control/binding row index on DataView controls? > >> >> > >> >> cheers
hi Ilya i found my problem is modify the underlying the datatable directly... but i get a new problem there... after i new dataview.addnew() method.. i get a indexofrangeexception in the datagrid.. can you help me out? thank you victor [quoted text, click to view] ""Ilya Tumanov [MS]"" <ilyatum@online.microsoft.com> wrote in message news:se6wTQDHFHA.1140@TK2MSFTNGXA02.phx.gbl... >I see nothing wrong with this code fragment, but since it's not your entire > application, problem might be somewhere else. > Make sure you do not delete/modify rows from/in the DataTable directly, > only from/in DataView. > Also make sure DataTable is not modified from other threads. > > Or come up with a repro (small, complete and compliable code) and post it > to the NG so I can investigate. > > Best regards, > > Ilya > > This posting is provided "AS IS" with no warranties, and confers no > rights. > -------------------- >> From: "Victor" <gang_shi@hotmail.com> >> References: <ucfR1FvGFHA.2360@TK2MSFTNGP12.phx.gbl> > <Yd#vrx2GFHA.1136@TK2MSFTNGXA02.phx.gbl> >> Subject: Re: Databinding Exception >> Date: Sat, 26 Feb 2005 20:41:12 +1300 >> Lines: 104 >> X-Priority: 3 >> X-MSMail-Priority: Normal >> X-Newsreader: Microsoft Outlook Express 6.00.2900.2527 >> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 >> X-RFC2646: Format=Flowed; Original >> Message-ID: <e7CJNa9GFHA.3076@tk2msftngp13.phx.gbl> >> Newsgroups: microsoft.public.dotnet.framework.compactframework >> NNTP-Posting-Host: 222-152-67-63.jetstream.xtra.co.nz 222.152.67.63 >> Path: > TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp1 > 3.phx.gbl >> Xref: TK2MSFTNGXA02.phx.gbl > microsoft.public.dotnet.framework.compactframework:71954 >> X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework >> >> Hi Ilya >> thanks for the reply. but i still get some confusion here. what do you > mean >> using control/binding row index as i row index in DataTable? >> In my program. i write something like >> >> public void AddDataBinding() >> { >> > this.cboCustomerName.DataBindings.Add("SelectedValue",this.dvCall,"CustomerC > ode"); >> > this.dpScheduleStartTime.DataBindings.Add("Value",this.dvCall,"ScheduleStart > ed"); >> > this.dpScheduleEndTime.DataBindings.Add("Value",this.dvCall,"ScheduleEnded") > ; >> >> > this.txtAcutalStartTime.DataBindings.Add("Text",this.dvCall,"ActualStarted") > ; >> > this.txtAcutalEndTime.DataBindings.Add("Text",this.dvCall,"ActualEnded"); >> >> > this.cboCallStatus.DataBindings.Add("SelectedValue",this.dvCall,"CallStatusI > D"); >> >> } >> >> public void ClearDataBinding() >> { >> this.cboCustomerName.DataBindings.Clear(); >> this.dpScheduleStartTime.DataBindings.Clear(); >> this.dpScheduleEndTime.DataBindings.Clear(); >> this.cboCallStatus.DataBindings.Clear(); >> this.txtAcutalStartTime.DataBindings.Clear(); >> } >> >> Did I do the right thing here? >> Am i using the control/binding row index on DataView controls? >> >> cheers >> victor >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> ""Ilya Tumanov [MS]"" <ilyatum@online.microsoft.com> wrote in message >> news:Yd%23vrx2GFHA.1136@TK2MSFTNGXA02.phx.gbl... >> > Most common reason for that problem is using control/binding row index > as >> > a >> > row index in DataTable. >> > Make sure you don't do that, use control/binding row index on DataView >> > controls are bound to instead. >> > >> > Best regards, >> > >> > Ilya >> > >> > This posting is provided "AS IS" with no warranties, and confers no >> > rights. >> > -------------------- >> >> From: "victor" <gshi@ebreathe.co.nz> >> >> Subject: Databinding Exception >> >> Date: Fri, 25 Feb 2005 17:21:16 +1300 >> >> Lines: 13 >> >> X-Priority: 3 >> >> X-MSMail-Priority: Normal >> >> X-Newsreader: Microsoft Outlook Express 6.00.2900.2527 >> >> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 >> >> X-RFC2646: Format=Flowed; Original >> >> Message-ID: <ucfR1FvGFHA.2360@TK2MSFTNGP12.phx.gbl> >> >> Newsgroups: microsoft.public.dotnet.framework.compactframework >> >> NNTP-Posting-Host: 203.97.94.50 >> >> Path: >> > > TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl!TK2MSFTNGP >> > 08.phx.gbl!TK2MSFTNGP12.phx.gbl >> >> Xref: TK2MSFTNGXA02.phx.gbl >> > microsoft.public.dotnet.framework.compactframework:71883 >> >> X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework >> >> >> >> hi guys >> >> i got a very strange problem here. In my program, i create the >> >> databinding >> >> between some textboxes ,comoboxes and a dataview. first i clear the >> >> databinding then add the databinding again. then i changed the current >> >> row >> >> in the dataview several times, the nullreferenceexception occurs.. > really >> >> dont why >> >> any suggestion? >> >> cheeers >> >> victor >> >> >> >> >> >> >> >> >> >> >> > >> >> >> >
hi Ilya.. I found another way to do this, but I am not sure it is the current one. before I use dataview.addnew() , i set the datagrid.datasource = null.. then i call addnew() and set the value to each column.. at last i set the datagrid.datasource = dataview again.. seems the problem fixed.. is that a possible way? cheers victor [quoted text, click to view] ""Ilya Tumanov [MS]"" <ilyatum@online.microsoft.com> wrote in message news:tfg1PoPHFHA.1140@TK2MSFTNGXA02.phx.gbl... > That's a known bug in DataGrid discussed just recently. > As a workaround, add data to the DataTable directly. > To do it safely, create empty row, set all columns and add it to the > table. > Or, better yet, use DataTable.Rows.Add() overload with array of objects to > set. > Do not set columns after row has been added. > I know it's confusing, sorry about that. This problem is fixed in CF V2. > > Best regards, > > Ilya > > This posting is provided "AS IS" with no warranties, and confers no > rights. > > -------------------- >> From: "Victor" <gang_shi@hotmail.com> >> References: <ucfR1FvGFHA.2360@TK2MSFTNGP12.phx.gbl> > <Yd#vrx2GFHA.1136@TK2MSFTNGXA02.phx.gbl> > <e7CJNa9GFHA.3076@tk2msftngp13.phx.gbl> > <se6wTQDHFHA.1140@TK2MSFTNGXA02.phx.gbl> >> Subject: Re: Databinding Exception >> Date: Sun, 27 Feb 2005 22:31:53 +1300 >> Lines: 171 >> X-Priority: 3 >> X-MSMail-Priority: Normal >> X-Newsreader: Microsoft Outlook Express 6.00.2900.2527 >> X-RFC2646: Format=Flowed; Original >> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 >> Message-ID: <OeIz3ELHFHA.1096@tk2msftngp13.phx.gbl> >> Newsgroups: microsoft.public.dotnet.framework.compactframework >> NNTP-Posting-Host: 222-152-67-63.jetstream.xtra.co.nz 222.152.67.63 >> Path: > TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp1 > 3.phx.gbl >> Xref: TK2MSFTNGXA02.phx.gbl > microsoft.public.dotnet.framework.compactframework:71983 >> X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework >> >> hi Ilya >> i found my problem is modify the underlying the datatable directly... >> but i get a new problem there... after i new dataview.addnew() method.. i >> get a indexofrangeexception in the datagrid.. >> >> can you help me out? >> thank you >> victor >> >> ""Ilya Tumanov [MS]"" <ilyatum@online.microsoft.com> wrote in message >> news:se6wTQDHFHA.1140@TK2MSFTNGXA02.phx.gbl... >> >I see nothing wrong with this code fragment, but since it's not your > entire >> > application, problem might be somewhere else. >> > Make sure you do not delete/modify rows from/in the DataTable directly, >> > only from/in DataView. >> > Also make sure DataTable is not modified from other threads. >> > >> > Or come up with a repro (small, complete and compliable code) and post > it >> > to the NG so I can investigate. >> > >> > Best regards, >> > >> > Ilya >> > >> > This posting is provided "AS IS" with no warranties, and confers no >> > rights. >> > -------------------- >> >> From: "Victor" <gang_shi@hotmail.com> >> >> References: <ucfR1FvGFHA.2360@TK2MSFTNGP12.phx.gbl> >> > <Yd#vrx2GFHA.1136@TK2MSFTNGXA02.phx.gbl> >> >> Subject: Re: Databinding Exception >> >> Date: Sat, 26 Feb 2005 20:41:12 +1300 >> >> Lines: 104 >> >> X-Priority: 3 >> >> X-MSMail-Priority: Normal >> >> X-Newsreader: Microsoft Outlook Express 6.00.2900.2527 >> >> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 >> >> X-RFC2646: Format=Flowed; Original >> >> Message-ID: <e7CJNa9GFHA.3076@tk2msftngp13.phx.gbl> >> >> Newsgroups: microsoft.public.dotnet.framework.compactframework >> >> NNTP-Posting-Host: 222-152-67-63.jetstream.xtra.co.nz 222.152.67.63 >> >> Path: >> > > TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp1 >> > 3.phx.gbl >> >> Xref: TK2MSFTNGXA02.phx.gbl >> > microsoft.public.dotnet.framework.compactframework:71954 >> >> X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework >> >> >> >> Hi Ilya >> >> thanks for the reply. but i still get some confusion here. what do you >> > mean >> >> using control/binding row index as i row index in DataTable? >> >> In my program. i write something like >> >> >> >> public void AddDataBinding() >> >> { >> >> >> > > this.cboCustomerName.DataBindings.Add("SelectedValue",this.dvCall,"CustomerC >> > ode"); >> >> >> > > this.dpScheduleStartTime.DataBindings.Add("Value",this.dvCall,"ScheduleStart >> > ed"); >> >> >> > > this.dpScheduleEndTime.DataBindings.Add("Value",this.dvCall,"ScheduleEnded") >> > ; >> >> >> >> >> > > this.txtAcutalStartTime.DataBindings.Add("Text",this.dvCall,"ActualStarted") >> > ; >> >> >> > > this.txtAcutalEndTime.DataBindings.Add("Text",this.dvCall,"ActualEnded"); >> >> >> >> >> > > this.cboCallStatus.DataBindings.Add("SelectedValue",this.dvCall,"CallStatusI >> > D"); >> >> >> >> } >> >> >> >> public void ClearDataBinding() >> >> { >> >> this.cboCustomerName.DataBindings.Clear(); >> >> this.dpScheduleStartTime.DataBindings.Clear(); >> >> this.dpScheduleEndTime.DataBindings.Clear(); >> >> this.cboCallStatus.DataBindings.Clear(); >> >> this.txtAcutalStartTime.DataBindings.Clear(); >> >> } >> >> >> >> Did I do the right thing here? >> >> Am i using the control/binding row index on DataView controls? >> >> >> >> cheers >> >> victor >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> ""Ilya Tumanov [MS]"" <ilyatum@online.microsoft.com> wrote in message >> >> news:Yd%23vrx2GFHA.1136@TK2MSFTNGXA02.phx.gbl... >> >> > Most common reason for that problem is using control/binding row > index >> > as >> >> > a >> >> > row index in DataTable. >> >> > Make sure you don't do that, use control/binding row index on > DataView >> >> > controls are bound to instead. >> >> > >> >> > Best regards, >> >> > >> >> > Ilya >> >> > >> >> > This posting is provided "AS IS" with no warranties, and confers no >> >> > rights. >> >> > -------------------- >> >> >> From: "victor" <gshi@ebreathe.co.nz> >> >> >> Subject: Databinding Exception >> >> >> Date: Fri, 25 Feb 2005 17:21:16 +1300 >> >> >> Lines: 13 >> >> >> X-Priority: 3 >> >> >> X-MSMail-Priority: Normal >> >> >> X-Newsreader: Microsoft Outlook Express 6.00.2900.2527 >> >> >> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 >> >> >> X-RFC2646: Format=Flowed; Original >> >> >> Message-ID: <ucfR1FvGFHA.2360@TK2MSFTNGP12.phx.gbl> >> >> >> Newsgroups: microsoft.public.dotnet.framework.compactframework >> >> >> NNTP-Posting-Host: 203.97.94.50 >> >> >> Path: >> >> > >> > > TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl!TK2MSFTNGP >> >> > 08.phx.gbl!TK2MSFTNGP12.phx.gbl >> >> >> Xref: TK2MSFTNGXA02.phx.gbl >> >> > microsoft.public.dotnet.framework.compactframework:71883 >> >> >> X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
HI Ilya sorry i have another question.. u said in the pervious post that we should do the changes in the dataview, not the underlying datatable. so can I call the datarowview.row.rejectchanges() method? i have a databinding between the dataview and datagrid. i change the value in the datarowview then i call datarowview.canceledit() but the data will not back to the oringal value... is there some way to reject the changes to the dataview? cheers victor [quoted text, click to view] ""Ilya Tumanov [MS]"" <ilyatum@online.microsoft.com> wrote in message news:C01OLTRHFHA.1140@TK2MSFTNGXA02.phx.gbl... > That would work, but it's slower as grid would rebind every time you're > adding a row. > If performance is acceptable, you sure can do it this way. > > Best regards, > > Ilya > > This posting is provided "AS IS" with no warranties, and confers no > rights. > > -------------------- >> From: "victor" <gshi@ebreathe.co.nz> >> References: <ucfR1FvGFHA.2360@TK2MSFTNGP12.phx.gbl> > <Yd#vrx2GFHA.1136@TK2MSFTNGXA02.phx.gbl> > <e7CJNa9GFHA.3076@tk2msftngp13.phx.gbl> > <se6wTQDHFHA.1140@TK2MSFTNGXA02.phx.gbl> > <OeIz3ELHFHA.1096@tk2msftngp13.phx.gbl> > <tfg1PoPHFHA.1140@TK2MSFTNGXA02.phx.gbl> >> Subject: Re: Databinding Exception >> Date: Mon, 28 Feb 2005 09:41:50 +1300 >> Lines: 240 >> X-Priority: 3 >> X-MSMail-Priority: Normal >> X-Newsreader: Microsoft Outlook Express 6.00.2900.2527 >> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 >> X-RFC2646: Format=Flowed; Original >> Message-ID: <OE$sEzQHFHA.2616@tk2msftngp13.phx.gbl> >> Newsgroups: microsoft.public.dotnet.framework.compactframework >> NNTP-Posting-Host: 203.97.94.50 >> Path: > TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp1 > 3.phx.gbl >> Xref: TK2MSFTNGXA02.phx.gbl > microsoft.public.dotnet.framework.compactframework:72001 >> X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework >> >> hi Ilya.. >> I found another way to do this, but I am not sure it is the current one. >> before I use dataview.addnew() , i set the datagrid.datasource = null.. > then >> i call addnew() and set the value to each column.. at last i set the >> datagrid.datasource = dataview again.. seems the problem fixed.. is that > a >> possible way? >> cheers >> victor >> >> >> ""Ilya Tumanov [MS]"" <ilyatum@online.microsoft.com> wrote in message >> news:tfg1PoPHFHA.1140@TK2MSFTNGXA02.phx.gbl... >> > That's a known bug in DataGrid discussed just recently. >> > As a workaround, add data to the DataTable directly. >> > To do it safely, create empty row, set all columns and add it to the >> > table. >> > Or, better yet, use DataTable.Rows.Add() overload with array of objects > to >> > set. >> > Do not set columns after row has been added. >> > I know it's confusing, sorry about that. This problem is fixed in CF >> > V2. >> > >> > Best regards, >> > >> > Ilya >> > >> > This posting is provided "AS IS" with no warranties, and confers no >> > rights. >> > >> > -------------------- >> >> From: "Victor" <gang_shi@hotmail.com> >> >> References: <ucfR1FvGFHA.2360@TK2MSFTNGP12.phx.gbl> >> > <Yd#vrx2GFHA.1136@TK2MSFTNGXA02.phx.gbl> >> > <e7CJNa9GFHA.3076@tk2msftngp13.phx.gbl> >> > <se6wTQDHFHA.1140@TK2MSFTNGXA02.phx.gbl> >> >> Subject: Re: Databinding Exception >> >> Date: Sun, 27 Feb 2005 22:31:53 +1300 >> >> Lines: 171 >> >> X-Priority: 3 >> >> X-MSMail-Priority: Normal >> >> X-Newsreader: Microsoft Outlook Express 6.00.2900.2527 >> >> X-RFC2646: Format=Flowed; Original >> >> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 >> >> Message-ID: <OeIz3ELHFHA.1096@tk2msftngp13.phx.gbl> >> >> Newsgroups: microsoft.public.dotnet.framework.compactframework >> >> NNTP-Posting-Host: 222-152-67-63.jetstream.xtra.co.nz 222.152.67.63 >> >> Path: >> > > TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp1 >> > 3.phx.gbl >> >> Xref: TK2MSFTNGXA02.phx.gbl >> > microsoft.public.dotnet.framework.compactframework:71983 >> >> X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework >> >> >> >> hi Ilya >> >> i found my problem is modify the underlying the datatable directly... >> >> but i get a new problem there... after i new dataview.addnew() > method.. i >> >> get a indexofrangeexception in the datagrid.. >> >> >> >> can you help me out? >> >> thank you >> >> victor >> >> >> >> ""Ilya Tumanov [MS]"" <ilyatum@online.microsoft.com> wrote in message >> >> news:se6wTQDHFHA.1140@TK2MSFTNGXA02.phx.gbl... >> >> >I see nothing wrong with this code fragment, but since it's not your >> > entire >> >> > application, problem might be somewhere else. >> >> > Make sure you do not delete/modify rows from/in the DataTable > directly, >> >> > only from/in DataView. >> >> > Also make sure DataTable is not modified from other threads. >> >> > >> >> > Or come up with a repro (small, complete and compliable code) and > post >> > it >> >> > to the NG so I can investigate. >> >> > >> >> > Best regards, >> >> > >> >> > Ilya >> >> > >> >> > This posting is provided "AS IS" with no warranties, and confers no >> >> > rights. >> >> > -------------------- >> >> >> From: "Victor" <gang_shi@hotmail.com> >> >> >> References: <ucfR1FvGFHA.2360@TK2MSFTNGP12.phx.gbl> >> >> > <Yd#vrx2GFHA.1136@TK2MSFTNGXA02.phx.gbl> >> >> >> Subject: Re: Databinding Exception >> >> >> Date: Sat, 26 Feb 2005 20:41:12 +1300 >> >> >> Lines: 104 >> >> >> X-Priority: 3 >> >> >> X-MSMail-Priority: Normal >> >> >> X-Newsreader: Microsoft Outlook Express 6.00.2900.2527 >> >> >> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 >> >> >> X-RFC2646: Format=Flowed; Original >> >> >> Message-ID: <e7CJNa9GFHA.3076@tk2msftngp13.phx.gbl> >> >> >> Newsgroups: microsoft.public.dotnet.framework.compactframework >> >> >> NNTP-Posting-Host: 222-152-67-63.jetstream.xtra.co.nz 222.152.67.63 >> >> >> Path: >> >> > >> > > TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp1 >> >> > 3.phx.gbl >> >> >> Xref: TK2MSFTNGXA02.phx.gbl >> >> > microsoft.public.dotnet.framework.compactframework:71954 >> >> >> X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework >> >> >> >> >> >> Hi Ilya >> >> >> thanks for the reply. but i still get some confusion here. what do > you >> >> > mean >> >> >> using control/binding row index as i row index in DataTable? >> >> >> In my program. i write something like >> >> >> >> >> >> public void AddDataBinding() >> >> >> { >> >> >> >> >> > >> > > this.cboCustomerName.DataBindings.Add("SelectedValue",this.dvCall,"CustomerC >> >> > ode"); >> >> >> >> >> > >> > > this.dpScheduleStartTime.DataBindings.Add("Value",this.dvCall,"ScheduleStart >> >> > ed"); >> >> >> >> >> > >> > > this.dpScheduleEndTime.DataBindings.Add("Value",this.dvCall,"ScheduleEnded") >> >> > ; >> >> >> >> >> >> >> >> > >> >
CancelEdit() won't work if you bind to a bunch of textboxes. It should be OK to use RejectChanges() on the row instead. Best regards, Ilya This posting is provided "AS IS" with no warranties, and confers no rights. -------------------- [quoted text, click to view] > From: "victor" <gshi@ebreathe.co.nz> > References: <ucfR1FvGFHA.2360@TK2MSFTNGP12.phx.gbl>
<Yd#vrx2GFHA.1136@TK2MSFTNGXA02.phx.gbl> <e7CJNa9GFHA.3076@tk2msftngp13.phx.gbl> <se6wTQDHFHA.1140@TK2MSFTNGXA02.phx.gbl> <OeIz3ELHFHA.1096@tk2msftngp13.phx.gbl> <tfg1PoPHFHA.1140@TK2MSFTNGXA02.phx.gbl> <OE$sEzQHFHA.2616@tk2msftngp13.phx.gbl> <C01OLTRHFHA.1140@TK2MSFTNGXA02.phx.gbl> [quoted text, click to view] > Subject: Re: Databinding Exception > Date: Mon, 28 Feb 2005 10:54:13 +1300 > Lines: 315 > X-Priority: 3 > X-MSMail-Priority: Normal > X-Newsreader: Microsoft Outlook Express 6.00.2900.2527 > X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 > X-RFC2646: Format=Flowed; Original > Message-ID: <#aHchbRHFHA.3200@TK2MSFTNGP12.phx.gbl> > Newsgroups: microsoft.public.dotnet.framework.compactframework > NNTP-Posting-Host: 203.97.94.50 > Path:
TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP1 2.phx.gbl [quoted text, click to view] > Xref: TK2MSFTNGXA02.phx.gbl microsoft.public.dotnet.framework.compactframework:72003 > X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework > > HI Ilya > sorry i have another question.. u said in the pervious post that we should > do the changes in the dataview, not the underlying datatable. so can I call > the datarowview.row.rejectchanges() method? > i have a databinding between the dataview and datagrid. i change the value > in the datarowview then i call datarowview.canceledit() but the data will > not back to the oringal value... > is there some way to reject the changes to the dataview? > cheers > victor > > ""Ilya Tumanov [MS]"" <ilyatum@online.microsoft.com> wrote in message > news:C01OLTRHFHA.1140@TK2MSFTNGXA02.phx.gbl... > > That would work, but it's slower as grid would rebind every time you're > > adding a row. > > If performance is acceptable, you sure can do it this way. > > > > Best regards, > > > > Ilya > > > > This posting is provided "AS IS" with no warranties, and confers no > > rights. > > > > -------------------- > >> From: "victor" <gshi@ebreathe.co.nz> > >> References: <ucfR1FvGFHA.2360@TK2MSFTNGP12.phx.gbl> > > <Yd#vrx2GFHA.1136@TK2MSFTNGXA02.phx.gbl> > > <e7CJNa9GFHA.3076@tk2msftngp13.phx.gbl> > > <se6wTQDHFHA.1140@TK2MSFTNGXA02.phx.gbl> > > <OeIz3ELHFHA.1096@tk2msftngp13.phx.gbl> > > <tfg1PoPHFHA.1140@TK2MSFTNGXA02.phx.gbl> > >> Subject: Re: Databinding Exception > >> Date: Mon, 28 Feb 2005 09:41:50 +1300 > >> Lines: 240 > >> X-Priority: 3 > >> X-MSMail-Priority: Normal > >> X-Newsreader: Microsoft Outlook Express 6.00.2900.2527 > >> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 > >> X-RFC2646: Format=Flowed; Original > >> Message-ID: <OE$sEzQHFHA.2616@tk2msftngp13.phx.gbl> > >> Newsgroups: microsoft.public.dotnet.framework.compactframework > >> NNTP-Posting-Host: 203.97.94.50 > >> Path: > > TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp1 > > 3.phx.gbl > >> Xref: TK2MSFTNGXA02.phx.gbl > > microsoft.public.dotnet.framework.compactframework:72001 > >> X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework > >> > >> hi Ilya.. > >> I found another way to do this, but I am not sure it is the current one. > >> before I use dataview.addnew() , i set the datagrid.datasource = null.. > > then > >> i call addnew() and set the value to each column.. at last i set the > >> datagrid.datasource = dataview again.. seems the problem fixed.. is that > > a > >> possible way? > >> cheers > >> victor > >> > >> > >> ""Ilya Tumanov [MS]"" <ilyatum@online.microsoft.com> wrote in message > >> news:tfg1PoPHFHA.1140@TK2MSFTNGXA02.phx.gbl... > >> > That's a known bug in DataGrid discussed just recently. > >> > As a workaround, add data to the DataTable directly. > >> > To do it safely, create empty row, set all columns and add it to the > >> > table. > >> > Or, better yet, use DataTable.Rows.Add() overload with array of objects > > to > >> > set. > >> > Do not set columns after row has been added. > >> > I know it's confusing, sorry about that. This problem is fixed in CF > >> > V2. > >> > > >> > Best regards, > >> > > >> > Ilya > >> > > >> > This posting is provided "AS IS" with no warranties, and confers no > >> > rights. > >> > > >> > -------------------- > >> >> From: "Victor" <gang_shi@hotmail.com> > >> >> References: <ucfR1FvGFHA.2360@TK2MSFTNGP12.phx.gbl> > >> > <Yd#vrx2GFHA.1136@TK2MSFTNGXA02.phx.gbl> > >> > <e7CJNa9GFHA.3076@tk2msftngp13.phx.gbl> > >> > <se6wTQDHFHA.1140@TK2MSFTNGXA02.phx.gbl> > >> >> Subject: Re: Databinding Exception > >> >> Date: Sun, 27 Feb 2005 22:31:53 +1300 > >> >> Lines: 171 > >> >> X-Priority: 3 > >> >> X-MSMail-Priority: Normal > >> >> X-Newsreader: Microsoft Outlook Express 6.00.2900.2527 > >> >> X-RFC2646: Format=Flowed; Original > >> >> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 > >> >> Message-ID: <OeIz3ELHFHA.1096@tk2msftngp13.phx.gbl> > >> >> Newsgroups: microsoft.public.dotnet.framework.compactframework > >> >> NNTP-Posting-Host: 222-152-67-63.jetstream.xtra.co.nz 222.152.67.63 > >> >> Path: > >> > > > TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp1 > >> > 3.phx.gbl > >> >> Xref: TK2MSFTNGXA02.phx.gbl > >> > microsoft.public.dotnet.framework.compactframework:71983 > >> >> X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework > >> >> > >> >> hi Ilya > >> >> i found my problem is modify the underlying the datatable directly... > >> >> but i get a new problem there... after i new dataview.addnew() > > method.. i > >> >> get a indexofrangeexception in the datagrid.. > >> >> > >> >> can you help me out? > >> >> thank you > >> >> victor > >> >> > >> >> ""Ilya Tumanov [MS]"" <ilyatum@online.microsoft.com> wrote in message > >> >> news:se6wTQDHFHA.1140@TK2MSFTNGXA02.phx.gbl... > >> >> >I see nothing wrong with this code fragment, but since it's not your > >> > entire > >> >> > application, problem might be somewhere else. > >> >> > Make sure you do not delete/modify rows from/in the DataTable > > directly, > >> >> > only from/in DataView. > >> >> > Also make sure DataTable is not modified from other threads. > >> >> > > >> >> > Or come up with a repro (small, complete and compliable code) and > > post > >> > it > >> >> > to the NG so I can investigate. > >> >> > > >> >> > Best regards, > >> >> > > >> >> > Ilya > >> >> > > >> >> > This posting is provided "AS IS" with no warranties, and confers no > >> >> > rights. > >> >> > -------------------- > >> >> >> From: "Victor" <gang_shi@hotmail.com> > >> >> >> References: <ucfR1FvGFHA.2360@TK2MSFTNGP12.phx.gbl>
I would be happy to help, but I'll need short, but complete and compliable repro I can actually run. If you'd come up with one, I'll take a look. Oh, by the way, there's no need to loop through rows to update SQL CE. Just use SqlCeDataAdapter.Update(), it would it for you, just set update/delete/insert commands as needed or use CommandBuilder (works if you have primary key). Best regards, Ilya This posting is provided "AS IS" with no warranties, and confers no rights. -------------------- [quoted text, click to view] > From: "victor" <gshi@ebreathe.co.nz> > References: <ucfR1FvGFHA.2360@TK2MSFTNGP12.phx.gbl>
<Yd#vrx2GFHA.1136@TK2MSFTNGXA02.phx.gbl> <e7CJNa9GFHA.3076@tk2msftngp13.phx.gbl> <se6wTQDHFHA.1140@TK2MSFTNGXA02.phx.gbl> <OeIz3ELHFHA.1096@tk2msftngp13.phx.gbl> <tfg1PoPHFHA.1140@TK2MSFTNGXA02.phx.gbl> <OE$sEzQHFHA.2616@tk2msftngp13.phx.gbl> <C01OLTRHFHA.1140@TK2MSFTNGXA02.phx.gbl> <#aHchbRHFHA.3200@TK2MSFTNGP12.phx.gbl> <sW4CC7bHFHA.2824@TK2MSFTNGXA02.phx.gbl> [quoted text, click to view] > Subject: Re: Databinding Exception > Date: Tue, 1 Mar 2005 11:26:13 +1300 > Lines: 343 > X-Priority: 3 > X-MSMail-Priority: Normal > X-Newsreader: Microsoft Outlook Express 6.00.2900.2527 > X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 > X-RFC2646: Format=Flowed; Original > Message-ID: <OI48ESeHFHA.2936@TK2MSFTNGP15.phx.gbl> > Newsgroups: microsoft.public.dotnet.framework.compactframework > NNTP-Posting-Host: 203.97.94.50 > Path:
TK2MSFTNGXA02.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTFEED02.phx.gbl!TK2MSFTNGP0 8.phx.gbl!TK2MSFTNGP15.phx.gbl [quoted text, click to view] > Xref: TK2MSFTNGXA02.phx.gbl microsoft.public.dotnet.framework.compactframework:72101 > X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework > > Hi Ilya, > > First I want to say sorry to bother you here. I wrote some threads about the > NullReferenceException occurred in my program. And you replied them. Now I > have change all bindings to dataview and do not modify underlying datatable > directly.. but the NullReferenceException still will come up.. I attached > the codewith the NullReferenceException here¡ would you mind have a little > look and give me some advice.. > > Thank you very much > > victor > > > > public class NewContactForm : System.Windows.Forms.Form > { > # region User defined variables > > private bool isNewMode = false; > private ReadOnlyDataGrid dgCustomerContacts; > private int customerCode; > private DataView dvCustomerContacts; > private SQLCEManager manager; > > #endregion > > > > public NewContactForm(int customerCode, ref DataTable dt) > { > // > // Required for Windows Form Designer support > // > InitializeComponent(); > > SIPCustomers = new Microsoft.WindowsCE.Forms.InputPanel(); > SIPCustomers.EnabledChanged +=new > EventHandler(SIPCustomers_EnabledChanged); > > manager = new SQLCEManager(); > this.customerCode = customerCode; > this.dvCustomerContacts = new DataView(dt); > > SetGridStyle(); > this.dgCustomerContacts.DataSource = dvCustomerContacts; > > if (dvCustomerContacts.Count > 0) > { > this.dgCustomerContacts.Select(0); > } > > AddCustomerContactDataBindings(); > > } > > /// <summary> > /// Clean up any resources being used. > /// </summary> > protected override void Dispose( bool disposing ) > { > base.Dispose( disposing ); > } > > //delete windows generate code > > private void SaveChanges() > { > try > { > foreach(DataRow row in this.dvCustomerContacts.Table.Rows) > { > if (row.RowState == DataRowState.Added) > { > string cmd = String.Format("INSERT INTO CustomerContact" + > "(CustomerCode, " + > "CustomerContactName, " + > "CustomerContactposition, " + > "CustomerContactMobilePhone) VALUES (" + > "'{0}','{1}','{2}','{3}')", > SQLCEManager.GetDatabaseString(row["CustomerCode"].ToString()), > SQLCEManager.GetDatabaseString(row["CustomerContactName"].ToString()), > SQLCEManager.GetDatabaseString(row["CustomerContactposition"].ToString()), >
SQLCEManager.GetDatabaseString(row["CustomerContactMobilePhone"].ToString()) ); [quoted text, click to view] > manager.ExecuteNonQuery(cmd); > > } > else if (row.RowState == DataRowState.Deleted) > { > row.RejectChanges(); > string cmd = String.Format("DELETE FROM CustomerContact WHERE > CustomerContactCode = '{0}'",row["CustomerContactCode"]); > manager.ExecuteNonQuery(cmd); > > } > else if (row.RowState == DataRowState.Modified ) > { > string cmd = String.Format("UPDATE CustomerContact " + > "SET CustomerCode ={0}, "+ > "CustomerContactName ='{1}', " + > "CustomerContactposition ='{2}', " + > "CustomerContactMobilePhone ='{3}'" + > "WHERE CustomerContactCode = '{4}'", > SQLCEManager.GetDatabaseString(row["CustomerCode"].ToString()), > SQLCEManager.GetDatabaseString(row["CustomerContactName"].ToString()), > SQLCEManager.GetDatabaseString(row["CustomerContactposition"].ToString()), >
SQLCEManager.GetDatabaseString(row["CustomerContactMobilePhone"].ToString()) , [quoted text, click to view] > SQLCEManager.GetDatabaseString(row["CustomerContactCode"].ToString()) > ); > manager.ExecuteNonQuery(cmd); > } > } > this.dvCustomerContacts.Table.AcceptChanges(); > } > catch(SqlCeException ex) > { > MessageBox.Show(ex.Message); > } > finally > { > manager.Close(); > } > > > } > > > private void SetGridStyle() > { > > this.dgCustomerContacts.RowHeadersVisible = false; > this.dgCustomerContacts.ContextMenu = this.mnuDelContact; > > this.pnlCustomerDetails.Controls.Add(this.dgCustomerContacts); > > > > DataGridTableStyle table = new DataGridTableStyle(); > table.MappingName = "CustomerContacts"; > > DataGridColumnStyle cName = new DataGridTextBoxColumn (); > cName.HeaderText = "Name"; > cName.MappingName = "CustomerContactName"; > cName.Width = 150; > > DataGridColumnStyle cPosition = new DataGridTextBoxColumn(); > cPosition.HeaderText = "Position"; > cPosition.MappingName = "CustomerContactposition"; > cPosition.Width = 77; > > table.GridColumnStyles.Add(cName); > table.GridColumnStyles.Add(cPosition); > > this.dgCustomerContacts.TableStyles.Add(table); > } > > private void AddCustomerContactDataBindings() > { > if (dvCustomerContacts != null) > { >
this.txtCustomerContactName.DataBindings.Add("Text",dvCustomerContacts,"Cust omerContactName"); [quoted text, click to view] >
this.txtCustomerContactposition.DataBindings.Add("Text",dvCustomerContacts," CustomerContactposition"); [quoted text, click to view] >
You can just remove "online" from my e-mail below. However, it would be best if you can cut out irrelevant code. I certainly do not need any confidential data you might have in your data base, besides short repro speeds up the process. For example, here's a repro for IndexOutOfRange exception in a grid. All I had to do is to drop grid and button on a form and add 8 lines of code. Just click of a button twice and you'll see the exception: using System; using System.Drawing; using System.Collections; using System.Windows.Forms; using System.Data; namespace SmartDeviceApplication1 { /// <summary> /// Summary description for Form1. /// </summary> public class Form1 : System.Windows.Forms.Form { private System.Windows.Forms.DataGrid dataGrid1; private System.Windows.Forms.Button button1; private System.Windows.Forms.MainMenu mainMenu1; private DataTable dt; public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // } /// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose( bool disposing ) { base.Dispose( disposing ); } #region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.mainMenu1 = new System.Windows.Forms.MainMenu(); this.dataGrid1 = new System.Windows.Forms.DataGrid(); this.button1 = new System.Windows.Forms.Button(); // // dataGrid1 // this.dataGrid1.Location = new System.Drawing.Point(0, 8); this.dataGrid1.Size = new System.Drawing.Size(240, 200); this.dataGrid1.Text = "dataGrid1"; // // button1 // this.button1.Location = new System.Drawing.Point(96, 224); this.button1.Text = "button1"; this.button1.Click += new System.EventHandler(this.button1_Click); // // Form1 // this.Controls.Add(this.button1); this.Controls.Add(this.dataGrid1); this.Menu = this.mainMenu1; this.Text = "Form1"; } #endregion /// <summary> /// The main entry point for the application. /// </summary> static void Main() { Application.Run(new Form1()); } private void button1_Click(object sender, System.EventArgs e) { if (dt == null) { dt = new DataTable(); dt.Columns.Add("Column"); this.dataGrid1.DataSource = dt; } dt.DefaultView.AddNew(); } } } Best regards, Ilya This posting is provided "AS IS" with no warranties, and confers no rights. -------------------- [quoted text, click to view] > From: "victor" <gshi@ebreathe.co.nz> > References: <ucfR1FvGFHA.2360@TK2MSFTNGP12.phx.gbl>
<Yd#vrx2GFHA.1136@TK2MSFTNGXA02.phx.gbl> <e7CJNa9GFHA.3076@tk2msftngp13.phx.gbl> <se6wTQDHFHA.1140@TK2MSFTNGXA02.phx.gbl> <OeIz3ELHFHA.1096@tk2msftngp13.phx.gbl> <tfg1PoPHFHA.1140@TK2MSFTNGXA02.phx.gbl> <OE$sEzQHFHA.2616@tk2msftngp13.phx.gbl> <C01OLTRHFHA.1140@TK2MSFTNGXA02.phx.gbl> <#aHchbRHFHA.3200@TK2MSFTNGP12.phx.gbl> <sW4CC7bHFHA.2824@TK2MSFTNGXA02.phx.gbl> <OI48ESeHFHA.2936@TK2MSFTNGP15.phx.gbl> <aa2oT9eHFHA.1140@TK2MSFTNGXA02.phx.gbl> [quoted text, click to view] > Subject: Re: Databinding Exception > Date: Tue, 1 Mar 2005 13:11:29 +1300 > Lines: 432 > X-Priority: 3 > X-MSMail-Priority: Normal > X-Newsreader: Microsoft Outlook Express 6.00.2900.2527 > X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 > X-RFC2646: Format=Flowed; Original > Message-ID: <eZ8w5MfHFHA.2924@TK2MSFTNGP15.phx.gbl> > Newsgroups: microsoft.public.dotnet.framework.compactframework > NNTP-Posting-Host: 203.97.94.50 > Path:
TK2MSFTNGXA02.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTFEED02.phx.gbl!TK2MSFTNGP0 8.phx.gbl!TK2MSFTNGP15.phx.gbl [quoted text, click to view] > Xref: TK2MSFTNGXA02.phx.gbl microsoft.public.dotnet.framework.compactframework:72107 > X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework > > Hi Ilya > would you mind give me you email address so that i can send the project > file...? In order to run the program.. i think i have to send you the whole > form.. > > thank you > victor > > ""Ilya Tumanov [MS]"" <ilyatum@online.microsoft.com> wrote in message > news:aa2oT9eHFHA.1140@TK2MSFTNGXA02.phx.gbl... > >I would be happy to help, but I'll need short, but complete and compliable > > repro I can actually run. > > If you'd come up with one, I'll take a look. > > > > Oh, by the way, there's no need to loop through rows to update SQL CE. > > Just use SqlCeDataAdapter.Update(), it would it for you, just set > > update/delete/insert commands as needed or use CommandBuilder (works if > > you > > have primary key). > > > > Best regards, > > > > Ilya > > > > This posting is provided "AS IS" with no warranties, and confers no > > rights. > > > > -------------------- > >> From: "victor" <gshi@ebreathe.co.nz> > >> References: <ucfR1FvGFHA.2360@TK2MSFTNGP12.phx.gbl> > > <Yd#vrx2GFHA.1136@TK2MSFTNGXA02.phx.gbl> > > <e7CJNa9GFHA.3076@tk2msftngp13.phx.gbl> > > <se6wTQDHFHA.1140@TK2MSFTNGXA02.phx.gbl> > > <OeIz3ELHFHA.1096@tk2msftngp13.phx.gbl> > > <tfg1PoPHFHA.1140@TK2MSFTNGXA02.phx.gbl> > > <OE$sEzQHFHA.2616@tk2msftngp13.phx.gbl> > > <C01OLTRHFHA.1140@TK2MSFTNGXA02.phx.gbl> > > <#aHchbRHFHA.3200@TK2MSFTNGP12.phx.gbl> > > <sW4CC7bHFHA.2824@TK2MSFTNGXA02.phx.gbl> > >> Subject: Re: Databinding Exception > >> Date: Tue, 1 Mar 2005 11:26:13 +1300 > >> Lines: 343 > >> X-Priority: 3 > >> X-MSMail-Priority: Normal > >> X-Newsreader: Microsoft Outlook Express 6.00.2900.2527 > >> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 > >> X-RFC2646: Format=Flowed; Original > >> Message-ID: <OI48ESeHFHA.2936@TK2MSFTNGP15.phx.gbl> > >> Newsgroups: microsoft.public.dotnet.framework.compactframework > >> NNTP-Posting-Host: 203.97.94.50 > >> Path: > > TK2MSFTNGXA02.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTFEED02.phx.gbl!TK2MSFTNGP0 > > 8.phx.gbl!TK2MSFTNGP15.phx.gbl > >> Xref: TK2MSFTNGXA02.phx.gbl > > microsoft.public.dotnet.framework.compactframework:72101 > >> X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework > >> > >> Hi Ilya, > >> > >> First I want to say sorry to bother you here. I wrote some threads about > > the > >> NullReferenceException occurred in my program. And you replied them. Now > > I > >> have change all bindings to dataview and do not modify underlying > > datatable > >> directly.. but the NullReferenceException still will come up.. I attached > >> the codewith the NullReferenceException here¡ would you mind have a > > little > >> look and give me some advice.. > >> > >> Thank you very much > >> > >> victor > >> > >> > >> > >> public class NewContactForm : System.Windows.Forms.Form > >> { > >> # region User defined variables > >>
Hi Ilya, First I want to say sorry to bother you here. I wrote some threads about the NullReferenceException occurred in my program. And you replied them. Now I have change all bindings to dataview and do not modify underlying datatable directly.. but the NullReferenceException still will come up.. I attached the codewith the NullReferenceException here¡ would you mind have a little look and give me some advice.. Thank you very much victor public class NewContactForm : System.Windows.Forms.Form { # region User defined variables private bool isNewMode = false; private ReadOnlyDataGrid dgCustomerContacts; private int customerCode; private DataView dvCustomerContacts; private SQLCEManager manager; #endregion public NewContactForm(int customerCode, ref DataTable dt) { // // Required for Windows Form Designer support // InitializeComponent(); SIPCustomers = new Microsoft.WindowsCE.Forms.InputPanel(); SIPCustomers.EnabledChanged +=new EventHandler(SIPCustomers_EnabledChanged); manager = new SQLCEManager(); this.customerCode = customerCode; this.dvCustomerContacts = new DataView(dt); SetGridStyle(); this.dgCustomerContacts.DataSource = dvCustomerContacts; if (dvCustomerContacts.Count > 0) { this.dgCustomerContacts.Select(0); } AddCustomerContactDataBindings(); } /// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose( bool disposing ) { base.Dispose( disposing ); } //delete windows generate code private void SaveChanges() { try { foreach(DataRow row in this.dvCustomerContacts.Table.Rows) { if (row.RowState == DataRowState.Added) { string cmd = String.Format("INSERT INTO CustomerContact" + "(CustomerCode, " + "CustomerContactName, " + "CustomerContactposition, " + "CustomerContactMobilePhone) VALUES (" + "'{0}','{1}','{2}','{3}')", SQLCEManager.GetDatabaseString(row["CustomerCode"].ToString()), SQLCEManager.GetDatabaseString(row["CustomerContactName"].ToString()), SQLCEManager.GetDatabaseString(row["CustomerContactposition"].ToString()), SQLCEManager.GetDatabaseString(row["CustomerContactMobilePhone"].ToString())); manager.ExecuteNonQuery(cmd); } else if (row.RowState == DataRowState.Deleted) { row.RejectChanges(); string cmd = String.Format("DELETE FROM CustomerContact WHERE CustomerContactCode = '{0}'",row["CustomerContactCode"]); manager.ExecuteNonQuery(cmd); } else if (row.RowState == DataRowState.Modified ) { string cmd = String.Format("UPDATE CustomerContact " + "SET CustomerCode ={0}, "+ "CustomerContactName ='{1}', " + "CustomerContactposition ='{2}', " + "CustomerContactMobilePhone ='{3}'" + "WHERE CustomerContactCode = '{4}'", SQLCEManager.GetDatabaseString(row["CustomerCode"].ToString()), SQLCEManager.GetDatabaseString(row["CustomerContactName"].ToString()), SQLCEManager.GetDatabaseString(row["CustomerContactposition"].ToString()), SQLCEManager.GetDatabaseString(row["CustomerContactMobilePhone"].ToString()), SQLCEManager.GetDatabaseString(row["CustomerContactCode"].ToString()) ); manager.ExecuteNonQuery(cmd); } } this.dvCustomerContacts.Table.AcceptChanges(); } catch(SqlCeException ex) { MessageBox.Show(ex.Message); } finally { manager.Close(); } } private void SetGridStyle() { this.dgCustomerContacts.RowHeadersVisible = false; this.dgCustomerContacts.ContextMenu = this.mnuDelContact; this.pnlCustomerDetails.Controls.Add(this.dgCustomerContacts); DataGridTableStyle table = new DataGridTableStyle(); table.MappingName = "CustomerContacts"; DataGridColumnStyle cName = new DataGridTextBoxColumn (); cName.HeaderText = "Name"; cName.MappingName = "CustomerContactName"; cName.Width = 150; DataGridColumnStyle cPosition = new DataGridTextBoxColumn(); cPosition.HeaderText = "Position"; cPosition.MappingName = "CustomerContactposition"; cPosition.Width = 77; table.GridColumnStyles.Add(cName); table.GridColumnStyles.Add(cPosition); this.dgCustomerContacts.TableStyles.Add(table); } private void AddCustomerContactDataBindings() { if (dvCustomerContacts != null) { this.txtCustomerContactName.DataBindings.Add("Text",dvCustomerContacts,"CustomerContactName"); this.txtCustomerContactposition.DataBindings.Add("Text",dvCustomerContacts,"CustomerContactposition"); this.txtCustomerContactmobilePhone.DataBindings.Add("Text",dvCustomerContacts,"CustomerContactmobilePhone"); } } private void CleaCustomerContactDataBindings() { this.txtCustomerContactmobilePhone.DataBindings.Clear(); this.txtCustomerContactName.DataBindings.Clear(); this.txtCustomerContactposition.DataBindings.Clear(); this.txtCustomerContactName.Text = ""; this.txtCustomerContactposition.Text = ""; this.txtCustomerContactmobilePhone.Text = ""; } private void NewContactForm_Closing(object sender, System.ComponentModel.CancelEventArgs e) { this.TopLevelControl.Focus(); if (this.dvCustomerContacts.Count > 0 && this.dgCustomerContacts.CurrentRowIndex >= 0) { this.dvCustomerContacts[this.dgCustomerContacts.CurrentRowIndex].EndEdit(); } isNewMode = false; SaveChanges(); } private void tbCustomerContact_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e) { if (e.Button == this.btnAddContact ) { if (isNewMode == false) { isNewMode = true; CleaCustomerContactDataBindings(); this.txtCustomerContactName.Focus(); this.btnAddContact.ImageIndex = 1; } else { isNewMode = false; this.txtCustomerContactName.Text = ""; this.txtCustomerContactmobilePhone.Text = ""; this.txtCustomerContactposition.Text = ""; AddCustomerContactDataBindings(); this.btnAddContact.ImageIndex = 0; this.TopLevelControl.Focus(); } } else if (e.Button == this.btnSaveContact) { if (isNewMode == true) { if (this.txtCustomerContactName.Text != "") { DataRow dtRow = this.dvCustomerContacts.Table.NewRow(); dtRow["CustomerCode"] = this.customerCode; dtRow["CustomerContactName"] = this.txtCustomerContactName.Text ; dtRow["CustomerContactposition"] = this.txtCustomerContactposition.Text; dtRow["CustomerContactmobilePhone"] = this.txtCustomerContactmobilePhone.Text;
Hi Ilya would you mind give me you email address so that i can send the project file...? In order to run the program.. i think i have to send you the whole form.. thank you victor [quoted text, click to view] ""Ilya Tumanov [MS]"" <ilyatum@online.microsoft.com> wrote in message news:aa2oT9eHFHA.1140@TK2MSFTNGXA02.phx.gbl... >I would be happy to help, but I'll need short, but complete and compliable > repro I can actually run. > If you'd come up with one, I'll take a look. > > Oh, by the way, there's no need to loop through rows to update SQL CE. > Just use SqlCeDataAdapter.Update(), it would it for you, just set > update/delete/insert commands as needed or use CommandBuilder (works if > you > have primary key). > > Best regards, > > Ilya > > This posting is provided "AS IS" with no warranties, and confers no > rights. > > -------------------- >> From: "victor" <gshi@ebreathe.co.nz> >> References: <ucfR1FvGFHA.2360@TK2MSFTNGP12.phx.gbl> > <Yd#vrx2GFHA.1136@TK2MSFTNGXA02.phx.gbl> > <e7CJNa9GFHA.3076@tk2msftngp13.phx.gbl> > <se6wTQDHFHA.1140@TK2MSFTNGXA02.phx.gbl> > <OeIz3ELHFHA.1096@tk2msftngp13.phx.gbl> > <tfg1PoPHFHA.1140@TK2MSFTNGXA02.phx.gbl> > <OE$sEzQHFHA.2616@tk2msftngp13.phx.gbl> > <C01OLTRHFHA.1140@TK2MSFTNGXA02.phx.gbl> > <#aHchbRHFHA.3200@TK2MSFTNGP12.phx.gbl> > <sW4CC7bHFHA.2824@TK2MSFTNGXA02.phx.gbl> >> Subject: Re: Databinding Exception >> Date: Tue, 1 Mar 2005 11:26:13 +1300 >> Lines: 343 >> X-Priority: 3 >> X-MSMail-Priority: Normal >> X-Newsreader: Microsoft Outlook Express 6.00.2900.2527 >> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 >> X-RFC2646: Format=Flowed; Original >> Message-ID: <OI48ESeHFHA.2936@TK2MSFTNGP15.phx.gbl> >> Newsgroups: microsoft.public.dotnet.framework.compactframework >> NNTP-Posting-Host: 203.97.94.50 >> Path: > TK2MSFTNGXA02.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTFEED02.phx.gbl!TK2MSFTNGP0 > 8.phx.gbl!TK2MSFTNGP15.phx.gbl >> Xref: TK2MSFTNGXA02.phx.gbl > microsoft.public.dotnet.framework.compactframework:72101 >> X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework >> >> Hi Ilya, >> >> First I want to say sorry to bother you here. I wrote some threads about > the >> NullReferenceException occurred in my program. And you replied them. Now > I >> have change all bindings to dataview and do not modify underlying > datatable >> directly.. but the NullReferenceException still will come up.. I attached >> the codewith the NullReferenceException here¡ would you mind have a > little >> look and give me some advice.. >> >> Thank you very much >> >> victor >> >> >> >> public class NewContactForm : System.Windows.Forms.Form >> { >> # region User defined variables >> >> private bool isNewMode = false; >> private ReadOnlyDataGrid dgCustomerContacts; >> private int customerCode; >> private DataView dvCustomerContacts; >> private SQLCEManager manager; >> >> #endregion >> >> >> >> public NewContactForm(int customerCode, ref DataTable dt) >> { >> // >> // Required for Windows Form Designer support >> // >> InitializeComponent(); >> >> SIPCustomers = new Microsoft.WindowsCE.Forms.InputPanel(); >> SIPCustomers.EnabledChanged +=new >> EventHandler(SIPCustomers_EnabledChanged); >> >> manager = new SQLCEManager(); >> this.customerCode = customerCode; >> this.dvCustomerContacts = new DataView(dt); >> >> SetGridStyle(); >> this.dgCustomerContacts.DataSource = dvCustomerContacts; >> >> if (dvCustomerContacts.Count > 0) >> { >> this.dgCustomerContacts.Select(0); >> } >> >> AddCustomerContactDataBindings(); >> >> } >> >> /// <summary> >> /// Clean up any resources being used. >> /// </summary> >> protected override void Dispose( bool disposing ) >> { >> base.Dispose( disposing ); >> } >> >> //delete windows generate code >> >> private void SaveChanges() >> { >> try >> { >> foreach(DataRow row in this.dvCustomerContacts.Table.Rows) >> { >> if (row.RowState == DataRowState.Added) >> { >> string cmd = String.Format("INSERT INTO CustomerContact" + >> "(CustomerCode, " + >> "CustomerContactName, " + >> "CustomerContactposition, " + >> "CustomerContactMobilePhone) VALUES (" + >> "'{0}','{1}','{2}','{3}')", >> SQLCEManager.GetDatabaseString(row["CustomerCode"].ToString()), >> > SQLCEManager.GetDatabaseString(row["CustomerContactName"].ToString()), >> > SQLCEManager.GetDatabaseString(row["CustomerContactposition"].ToString()), >> > SQLCEManager.GetDatabaseString(row["CustomerContactMobilePhone"].ToString()) > ); >> manager.ExecuteNonQuery(cmd); >> >> } >> else if (row.RowState == DataRowState.Deleted) >> { >> row.RejectChanges(); >> string cmd = String.Format("DELETE FROM CustomerContact WHERE >> CustomerContactCode = '{0}'",row["CustomerContactCode"]); >> manager.ExecuteNonQuery(cmd); >> >> } >> else if (row.RowState == DataRowState.Modified ) >> { >> string cmd = String.Format("UPDATE CustomerContact " + >> "SET CustomerCode ={0}, "+ >> "CustomerContactName ='{1}', " + >> "CustomerContactposition ='{2}', " + >> "CustomerContactMobilePhone ='{3}'" + >> "WHERE CustomerContactCode = '{4}'", >> SQLCEManager.GetDatabaseString(row["CustomerCode"].ToString()), >> > SQLCEManager.GetDatabaseString(row["CustomerContactName"].ToString()), >> > SQLCEManager.GetDatabaseString(row["CustomerContactposition"].ToString()), >> > SQLCEManager.GetDatabaseString(row["CustomerContactMobilePhone"].ToString()) > , >> > SQLCEManager.GetDatabaseString(row["CustomerContactCode"].ToString()) >> ); >> manager.ExecuteNonQuery(cmd); >> } >> } >> this.dvCustomerContacts.Table.AcceptChanges(); >> } >> catch(SqlCeException ex) >> { >> MessageBox.Show(ex.Message); >> } >> finally >> { >> manager.Close(); >> } >> >> >> } >> >> >> private void SetGridStyle() >> { >> >> this.dgCustomerContacts.RowHeadersVisible = false; >> this.dgCustomerContacts.ContextMenu = this.mnuDelContact; >> >> this.pnlCustomerDetails.Controls.Add(this.dgCustomerContacts); >> >> >> >> DataGridTableStyle table = new DataGridTableStyle(); >> table.MappingName = "CustomerContacts"; >> >> DataGridColumnStyle cName = new DataGridTextBoxColumn (); >> cName.HeaderText = "Name"; >> cName.MappingName = "CustomerContactName"; >> cName.Width = 150; >> >> DataGridColumnStyle cPosition = new DataGridTextBoxColumn(); >> cPosition.HeaderText = "Position"; >> cPosition.MappingName = "CustomerContactposition"; >> cPosition.Width = 77; >> >> table.GridColumnStyles.Add(cName); >> table.GridColumnStyles.Add(cPosition);
Don't see what you're looking for? Try a search.
|
|
|