473,473 Members | 1,841 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Instantiating a form's dataset

I'm trying to create a preview shot of a record being edited, so I want to
take the current state and pass it to a instance of a form I have. I've tried
to create a dataView and pass that, but it has been failing.

System.Data.DataRowView drvCurrent;
System.Data.DataView dvNew;
dvNew = new System.Data.DataView();
drvCurrent = (System.Data.DataRowView)this.ds1.Message;
dvNew.Table = this.ds1.Message;
dvNew.RowFilter="MessageID = '" +drvCurrent[0] +"'";
Form frmTemp = new frmPreview(dvNew);

I could iterate through the active controls, but the form takes care of
formatting based on the contents of the record it's reading.

Thanks in advance,

E.
Nov 16 '05 #1
6 1677
Hi
why did it fail , what is the error message ?
did you create a construcor on your rmPreview class that take dataview
object as an input paramter, also you need to save that input param that
you get from the constructor in private dataview inside that class . if you
already have that please explain more what is the error that you get
Mohamed Mahfouz
MEA Developer Support Center
ITworx on behalf of Microsoft EMEA GTSC

Nov 16 '05 #2
The DataView was not being handled at all in the class, it just passed
through the try block as though it had an error and never processed (no error
message, just no results). Looking closer, the try block and class
constructor don't have a method to process it. Thanks for the reply,
Mohamoss, I should have seen it sooner.

E.

"Mohamoss" wrote:
Hi
why did it fail , what is the error message ?
did you create a construcor on your rmPreview class that take dataview
object as an input paramter, also you need to save that input param that
you get from the constructor in private dataview inside that class . if you
already have that please explain more what is the error that you get
Mohamed Mahfouz
MEA Developer Support Center
ITworx on behalf of Microsoft EMEA GTSC

Nov 16 '05 #3
Esteban404,

Is ds1 a DataSet? If so, you have to pass the table in the data set to
the data view. You can't just cast a data set (or data table for that
matter) to a DataView. The view encapsulates the DataTable, not extends it.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Esteban404" <Es********@discussions.microsoft.com> wrote in message
news:6D**********************************@microsof t.com...
The DataView was not being handled at all in the class, it just passed
through the try block as though it had an error and never processed (no
error
message, just no results). Looking closer, the try block and class
constructor don't have a method to process it. Thanks for the reply,
Mohamoss, I should have seen it sooner.

E.

"Mohamoss" wrote:
Hi
why did it fail , what is the error message ?
did you create a construcor on your rmPreview class that take dataview
object as an input paramter, also you need to save that input param that
you get from the constructor in private dataview inside that class . if
you
already have that please explain more what is the error that you get
Mohamed Mahfouz
MEA Developer Support Center
ITworx on behalf of Microsoft EMEA GTSC

Nov 16 '05 #4
Thanks for the reply. I know I'm going to have to write new constructors at
least.

I'm not great with the lingo of .NET yet. What I'm trying to pass is the
contents of the current record being edited (only) to the constructors of the
form used to display the contents of a datasource. This is to provide the
user a preview of their content. I thought there was a specific way to create
such a reference without passing individual member values, a list object or
something. I thought a dataset or dataview was the way to go. I won't be
shocked if I'm wrong.

E.

"Nicholas Paldino [.NET/C# MVP]" wrote:
Esteban404,

Is ds1 a DataSet? If so, you have to pass the table in the data set to
the data view. You can't just cast a data set (or data table for that
matter) to a DataView. The view encapsulates the DataTable, not extends it.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Esteban404" <Es********@discussions.microsoft.com> wrote in message
news:6D**********************************@microsof t.com...
The DataView was not being handled at all in the class, it just passed
through the try block as though it had an error and never processed (no
error
message, just no results). Looking closer, the try block and class
constructor don't have a method to process it. Thanks for the reply,
Mohamoss, I should have seen it sooner.

E.

"Mohamoss" wrote:
Hi
why did it fail , what is the error message ?
did you create a construcor on your rmPreview class that take dataview
object as an input paramter, also you need to save that input param that
you get from the constructor in private dataview inside that class . if
you
already have that please explain more what is the error that you get
Mohamed Mahfouz
MEA Developer Support Center
ITworx on behalf of Microsoft EMEA GTSC


Nov 16 '05 #5
Esteban,

Yes, there is a way to do this. Basically, you want to look at the
BindingContext of the form that has the record that is being viewed. What
you can then do is set the data source on the new form to the same data
source of the old form (it must be the same thing, the DataSet or the
DataTable or the DataView, they can not be different). Once you do that,
you can set the Current property of the BindingContext of the new form to
the Current property of the binding context of the old form, and your
controls should be pointing at the same record (although they will keep
separate pointers, because they are separate binding contexts).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Esteban404" <Es********@discussions.microsoft.com> wrote in message
news:0E**********************************@microsof t.com...
Thanks for the reply. I know I'm going to have to write new constructors
at
least.

I'm not great with the lingo of .NET yet. What I'm trying to pass is the
contents of the current record being edited (only) to the constructors of
the
form used to display the contents of a datasource. This is to provide the
user a preview of their content. I thought there was a specific way to
create
such a reference without passing individual member values, a list object
or
something. I thought a dataset or dataview was the way to go. I won't be
shocked if I'm wrong.

E.

"Nicholas Paldino [.NET/C# MVP]" wrote:
Esteban404,

Is ds1 a DataSet? If so, you have to pass the table in the data set
to
the data view. You can't just cast a data set (or data table for that
matter) to a DataView. The view encapsulates the DataTable, not extends
it.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Esteban404" <Es********@discussions.microsoft.com> wrote in message
news:6D**********************************@microsof t.com...
> The DataView was not being handled at all in the class, it just passed
> through the try block as though it had an error and never processed (no
> error
> message, just no results). Looking closer, the try block and class
> constructor don't have a method to process it. Thanks for the reply,
> Mohamoss, I should have seen it sooner.
>
> E.
>
> "Mohamoss" wrote:
>
>> Hi
>> why did it fail , what is the error message ?
>> did you create a construcor on your rmPreview class that take
>> dataview
>> object as an input paramter, also you need to save that input param
>> that
>> you get from the constructor in private dataview inside that class .
>> if
>> you
>> already have that please explain more what is the error that you get
>> Mohamed Mahfouz
>> MEA Developer Support Center
>> ITworx on behalf of Microsoft EMEA GTSC
>>
>>


Nov 16 '05 #6
Thanks Nicholas! That's exactly what I was trying to communicate I want to do.

Do I pass them like this:
Form frmPreview = new frmDisplay(this.BindingContext[ds1,"Message"].Current,
false);

The two parameters are for the data and to not enable the timer, just wait
for a click to close the preview. I just need to build constructors for these
then.

I'll keep looking for information on bindingContext and parameters until I
get it right!

E.

"Nicholas Paldino [.NET/C# MVP]" wrote:
Esteban,

Yes, there is a way to do this. Basically, you want to look at the
BindingContext of the form that has the record that is being viewed. What
you can then do is set the data source on the new form to the same data
source of the old form (it must be the same thing, the DataSet or the
DataTable or the DataView, they can not be different). Once you do that,
you can set the Current property of the BindingContext of the new form to
the Current property of the binding context of the old form, and your
controls should be pointing at the same record (although they will keep
separate pointers, because they are separate binding contexts).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Esteban404" <Es********@discussions.microsoft.com> wrote in message
news:0E**********************************@microsof t.com...
Thanks for the reply. I know I'm going to have to write new constructors
at
least.

I'm not great with the lingo of .NET yet. What I'm trying to pass is the
contents of the current record being edited (only) to the constructors of
the
form used to display the contents of a datasource. This is to provide the
user a preview of their content. I thought there was a specific way to
create
such a reference without passing individual member values, a list object
or
something. I thought a dataset or dataview was the way to go. I won't be
shocked if I'm wrong.

E.

"Nicholas Paldino [.NET/C# MVP]" wrote:
Esteban404,

Is ds1 a DataSet? If so, you have to pass the table in the data set
to
the data view. You can't just cast a data set (or data table for that
matter) to a DataView. The view encapsulates the DataTable, not extends
it.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Esteban404" <Es********@discussions.microsoft.com> wrote in message
news:6D**********************************@microsof t.com...
> The DataView was not being handled at all in the class, it just passed
> through the try block as though it had an error and never processed (no
> error
> message, just no results). Looking closer, the try block and class
> constructor don't have a method to process it. Thanks for the reply,
> Mohamoss, I should have seen it sooner.
>
> E.
>
> "Mohamoss" wrote:
>
>> Hi
>> why did it fail , what is the error message ?
>> did you create a construcor on your rmPreview class that take
>> dataview
>> object as an input paramter, also you need to save that input param
>> that
>> you get from the constructor in private dataview inside that class .
>> if
>> you
>> already have that please explain more what is the error that you get
>> Mohamed Mahfouz
>> MEA Developer Support Center
>> ITworx on behalf of Microsoft EMEA GTSC
>>
>>


Nov 16 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Esteban404 | last post by:
I defined a form object with databinding: frmDisplay. When the dataset of that form has displayed its content 5 times, I need to instantiate a new copy of the form and display that content. Here is...
4
by: Tom | last post by:
I have a VB.NET framework 1.1 application that I am installing on my user's workstation. It works fine on EVERY machine except for one - on this one machine it generates a 'Overflow or underflow in...
3
by: Nagesh | last post by:
hi, I have seen the winvnc(tightvnc server) source code in this I seen that class member funtions are calling without instantiating the object i.e. like vncService::ShowDefaultProperties() where...
4
by: Ronald S. Cook | last post by:
So most of the time I need to write the following to instantiate an object: Dim cnn As New SqlConnection() But sometimes Intellisense tells me not to include the "new": Dim dst As DataSet ...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.