473,387 Members | 1,374 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Composite DataKeyField?

Is there any option we can use Composite DataKeyField in the DataList and
DataGrid?
Nov 18 '05 #1
4 4029
Are your strying to store more than one item of data in an item?
"Ismail Rajput" <hu************@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Is there any option we can use Composite DataKeyField in the DataList and
DataGrid?

Nov 18 '05 #2
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" <so*****@microsoft.com> wrote in message
news:Oq**************@TK2MSFTNGP10.phx.gbl...
Are your strying to store more than one item of data in an item?
"Ismail Rajput" <hu************@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Is there any option we can use Composite DataKeyField in the DataList and DataGrid?


Nov 18 '05 #3
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" <hu************@hotmail.com> wrote in message
news:u4**************@TK2MSFTNGP10.phx.gbl...
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" <so*****@microsoft.com> wrote in message
news:Oq**************@TK2MSFTNGP10.phx.gbl...
Are your strying to store more than one item of data in an item?
"Ismail Rajput" <hu************@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Is there any option we can use Composite DataKeyField in the DataList and DataGrid?



Nov 18 '05 #4
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" <do***********@yahoo.com> wrote in message
news:uj**************@TK2MSFTNGP10.phx.gbl...
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" <hu************@hotmail.com> wrote in message
news:u4**************@TK2MSFTNGP10.phx.gbl...
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" <so*****@microsoft.com> wrote in message
news:Oq**************@TK2MSFTNGP10.phx.gbl...
Are your strying to store more than one item of data in an item?
"Ismail Rajput" <hu************@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
> Is there any option we can use Composite DataKeyField in the
DataList and
> DataGrid?
>
>



Nov 18 '05 #5

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

Similar topics

1
by: rufus | last post by:
Hi, I was wondering how a DataGrid can handle a DataSet with a composite key. How would I update 1 row in a database having a composite key? A possible solution would be to concatenate my...
0
by: A frustrated developer | last post by:
I would like to find a specific row on web datagrid, locate its pageindex and itemindex, then highlight to the specific row I found. I know its datakeyfield value, is there anyway we could search...
0
by: A frustrated developer | last post by:
I would like to find a specific row on web datagrid, then highlight the row by its pageindex and itemindex on that page. I know its datakeyfield, is there a way to find the row by its datakeyfield...
0
by: A frustrated developer | last post by:
I would like to find a specific row on the web datagrid, then highlight the row by its pageindex and itemindex on that page. I know its datakeyfield, is there a way to find the row by its...
0
by: AshifToday | last post by:
this was my and my frineds little project in earlier classes, the program seperates the composite and prime numbers in two sections of the screen ===================== /* This program has...
18
by: Thomas A. Anderson | last post by:
I am a bit confused in creating a composite primary key. I have three table with two of the tables containing primary keys. I have two of the tables (each with a primary key) having one to many...
0
by: sramruttun | last post by:
hi In my database I have a table in which 3 fields make up the primary key. I use a datagrid to add, edit/update and delete entries of that table. To facilitate this work we often use the...
0
by: Adam Knight | last post by:
I have a datagrid like so: <asp:DataGrid ID="dgSubAreas" Runat="server" AutoGenerateColumns="False" DataKeyField="" DataSource='<%# Container.DataItem.Row.GetChildRows("relSubAreas") %>'> ...
14
by: dave.dolan | last post by:
Basically I'd like to implement the composite design pattern with leaves that are either of reference or value types, but even using generics I can't seem to avoid boxing (using ArrayList or...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.