1,105,286 Community Members

DataList

Member Avatar
crazydevelopervish
Light Poster
26 posts since Jul 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

Is it possible to set two DataKeyField in DataList...........
If yes then pls help me out...................

Member Avatar
AleMonteiro
Master Poster
758 posts since Aug 2010
Reputation Points: 115 [?]
Q&As Helped to Solve: 143 [?]
Skill Endorsements: 29 [?]
 
0
 

Try like this:

myDataList.DataKeyFields = "myCol1,myCol2";
Member Avatar
crazydevelopervish
Light Poster
26 posts since Jul 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

and then how can i retrive value from it.....
general code is as follows...

DataList1.DataKeyField = "Customer_ID,Product_ID";
String Product_ID = DataList1.DataKeys[e.Item.ItemIndex].ToString();
String Customer_ID = DataList1.DataKeys[e.Item.ItemIndex].ToString();

Member Avatar
AleMonteiro
Master Poster
758 posts since Aug 2010
Reputation Points: 115 [?]
Q&As Helped to Solve: 143 [?]
Skill Endorsements: 29 [?]
 
2
 

Maybe like this:

string keys[] = DataList1.DataKeys[e.Item.ItemIndex].ToString().split(',');
string productId = keys[0];
string customerId = keys[1];
Member Avatar
crazydevelopervish
Light Poster
26 posts since Jul 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

not working geting error after including
string keys fixed[]=DataList1.DataKeys[e.Item.ItemIndex].ToString().Split(',');

Error 559 The type of a local declared in a fixed statement must be a pointer type

Member Avatar
AleMonteiro
Master Poster
758 posts since Aug 2010
Reputation Points: 115 [?]
Q&As Helped to Solve: 143 [?]
Skill Endorsements: 29 [?]
 
0
 

What does DataList1.DataKeys[e.Item.ItemIndex] returns?
Debug and see what's the value.

Member Avatar
crazydevelopervish
Light Poster
26 posts since Jul 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 
it returns only Customer_ID
Member Avatar
AleMonteiro
Master Poster
758 posts since Aug 2010
Reputation Points: 115 [?]
Q&As Helped to Solve: 143 [?]
Skill Endorsements: 29 [?]
 
0
 

Sorry, but for what I searched it's not possible to do what you want. DataList doesn't support composite keys, as DataGrid supports.

Take a look at those links:
http://stackoverflow.com/questions/3669949/datakeys-datalist

http://forums.asp.net/t/1665469.aspx/1

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article