Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Composite DataKeyField?

Reply
Thread Tools

Composite DataKeyField?

 
 
Felbrigg
Guest
Posts: n/a
 
      02-09-2004
Are your strying to store more than one item of data in an item?


"Ismail Rajput" <> wrote in message
news:%...
> Is there any option we can use Composite DataKeyField in the DataList and
> DataGrid?
>
>



 
Reply With Quote
 
 
 
 
Ismail Rajput
Guest
Posts: n/a
 
      02-10-2004
Is there any option we can use Composite DataKeyField in the DataList and
DataGrid?


 
Reply With Quote
 
 
 
 
Marshal Antony
Guest
Posts: n/a
 
      02-10-2004
Ismail,
If I understand correctly,you need to use a DataKeyField with both catid
and prodid information.
This may not be the straight forward way but here is how you can do this.
In your sql concatenate two of these columns which you want as composite
key separated by a charater say /.
For eg: in SQL Server
Select (catid + '/' + prodid) as catid_prodid,..........from
table_name
Set the DataKeyField as catid_prodid and do a split
to separate them before you make your UPDATE statement.
string[] compositecols=cateidprodid.Split('/');
compositecols[0] and compositecols[1] will have catid and prodid
respectively.
There might be some other way which I am not sure.
Hope this helps.
Regards,
Marshal Antony
..NET Developer
http://www.dotnetmarshal.com


"Ismail Rajput" <> wrote in message
news:...
> As Composite Key concept says that there can
> be more than one primary keys in a database table .
>
> I want two different columns to store two primary keys and both of them

make
> composite key in my database
>
> here we can have only one key
> Dim productID As String =
> MyDataList.DataKeys(MyDataList.SelectedItem.ItemIn dex)
>
>
> CategoryID and ProductID together make composite key in my database.I

faced
> this problem when updating database record having composite key ,
>
> i give you more detail
> catid = 001 prodid =001
> catid = 001 prodid =002
> catid=002 prodid =001
>
> If you look in primary keys , records are repeating but as composite they
> are not .
>
> if i update record with prodid then i will have two records updated .
>
> "Felbrigg" <> wrote in message
> news:...
> > Are your strying to store more than one item of data in an item?
> >
> >
> > "Ismail Rajput" <> wrote in message
> > news:%...
> > > Is there any option we can use Composite DataKeyField in the DataList

> and
> > > DataGrid?
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
Ismail Rajput
Guest
Posts: n/a
 
      02-10-2004
As Composite Key concept says that there can
be more than one primary keys in a database table .

I want two different columns to store two primary keys and both of them make
composite key in my database

here we can have only one key
Dim productID As String =
MyDataList.DataKeys(MyDataList.SelectedItem.ItemIn dex)


CategoryID and ProductID together make composite key in my database.I faced
this problem when updating database record having composite key ,

i give you more detail
catid = 001 prodid =001
catid = 001 prodid =002
catid=002 prodid =001

If you look in primary keys , records are repeating but as composite they
are not .

if i update record with prodid then i will have two records updated .

"Felbrigg" <> wrote in message
news:...
> Are your strying to store more than one item of data in an item?
>
>
> "Ismail Rajput" <> wrote in message
> news:%...
> > Is there any option we can use Composite DataKeyField in the DataList

and
> > DataGrid?
> >
> >

>
>



 
Reply With Quote
 
Ismail Rajput
Guest
Posts: n/a
 
      02-11-2004
Marshal ,

Thanks and yes you got correctly as i wanted it to be understood
..I think this is the best possible way ,the way you told me to do this.


"Marshal Antony" <> wrote in message
news:...
> Ismail,
> If I understand correctly,you need to use a DataKeyField with both

catid
> and prodid information.
> This may not be the straight forward way but here is how you can do this.
> In your sql concatenate two of these columns which you want as composite
> key separated by a charater say /.
> For eg: in SQL Server
> Select (catid + '/' + prodid) as catid_prodid,..........from
> table_name
> Set the DataKeyField as catid_prodid and do a

split
> to separate them before you make your UPDATE statement.
> string[] compositecols=cateidprodid.Split('/');
> compositecols[0] and compositecols[1] will have catid and prodid
> respectively.
> There might be some other way which I am not sure.
> Hope this helps.
> Regards,
> Marshal Antony
> .NET Developer
> http://www.dotnetmarshal.com
>
>
> "Ismail Rajput" <> wrote in message
> news:...
> > As Composite Key concept says that there can
> > be more than one primary keys in a database table .
> >
> > I want two different columns to store two primary keys and both of them

> make
> > composite key in my database
> >
> > here we can have only one key
> > Dim productID As String =
> > MyDataList.DataKeys(MyDataList.SelectedItem.ItemIn dex)
> >
> >
> > CategoryID and ProductID together make composite key in my database.I

> faced
> > this problem when updating database record having composite key ,
> >
> > i give you more detail
> > catid = 001 prodid =001
> > catid = 001 prodid =002
> > catid=002 prodid =001
> >
> > If you look in primary keys , records are repeating but as composite

they
> > are not .
> >
> > if i update record with prodid then i will have two records updated .
> >
> > "Felbrigg" <> wrote in message
> > news:...
> > > Are your strying to store more than one item of data in an item?
> > >
> > >
> > > "Ismail Rajput" <> wrote in message
> > > news:%...
> > > > Is there any option we can use Composite DataKeyField in the

DataList
> > and
> > > > DataGrid?
> > > >
> > > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

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
Composite vs non composite Controls Mike ASP .Net Web Controls 4 03-11-2005 05:47 AM
Losing Composite Control property that another Composite Control ... Chad ASP .Net Building Controls 0 02-01-2005 09:01 PM
Possible to create a composite control that has a child control that is a validator that validates the composite control itself? Jonathan Eric Miller ASP .Net Building Controls 2 07-22-2004 10:58 PM
Composite control with dynamic composite controls sleigh ASP .Net 1 02-12-2004 06:24 PM
composite inout signals with different driver directions Ralph Friedrich VHDL 1 11-07-2003 11:05 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57