public partial class ParentStudent
{
public int ParentStudentID { set; get; }
public int studentID { set; get; }
public string ParentStudentPhone { set; get; }
}
public partial class ParentStudent
{
//Added computed field here.
public string ComputedProperty
{
get {return Do whatever you want here, In the UI, bind the control to computed field.;}
}
}
congthanh105
Member
2 Points
12 Posts
About Primary key, please help
Dec 05, 2012 01:51 AM|LINK
And Could I ask about Primary key
I have 1 model:
public class student { public int studentID { set; get; } public string studentName{ set; get; } public string studentAge{ set; get; } }And ParentStudent.cs model
Then I creat controller for both model, with model ParentStudent, I just want to ask, In Creat Action of ParentStudentController
It have: 1Dropdowlist show all Student name:
1TextBox to input ParentStudentPhone
Question is: I already have 1Student in my ParentStudent table, and I creat more, it still save to my ParentStudent table @@
It mean 1 student have 2 ParentStudentPhone or more :S
I want only 1 student have 1ParentStudentPhone only
====================
how can I do that? please help me?
thaicarrot
Contributor
5132 Points
1465 Posts
Re: About Primary key, please help
Dec 05, 2012 03:40 AM|LINK
I just scan up your word. If you need One-To-One relationship both PK should be the same.
Weera
congthanh105
Member
2 Points
12 Posts
Re: About Primary key, please help
Dec 05, 2012 08:29 AM|LINK
I have 1 Field in table
It is normal field
but I want the data in this field are diffirent with each other?
Is it possible?
thaicarrot
Contributor
5132 Points
1465 Posts
Re: About Primary key, please help
Dec 05, 2012 08:54 AM|LINK
Do you know partial class?
How to: Add Computed Properties
Following link will solve your problem, Event if it is relate to Silverlight.
http://msdn.microsoft.com/en-us/library/ee707331(v=vs.91).aspx
Weera
thaicarrot
Contributor
5132 Points
1465 Posts
Re: About Primary key, please help
Dec 05, 2012 08:58 AM|LINK
public partial class ParentStudent { public int ParentStudentID { set; get; } public int studentID { set; get; } public string ParentStudentPhone { set; get; } } public partial class ParentStudent { //Added computed field here. public string ComputedProperty { get {return Do whatever you want here, In the UI, bind the control to computed field.;} } }Weera
congthanh105
Member
2 Points
12 Posts
Re: About Primary key, please help
Dec 05, 2012 09:18 AM|LINK
Thanks your help so much :)
You are pretty good :XD
have a nice health
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: About Primary key, please help
Dec 06, 2012 01:02 AM|LINK
Hi,
Since your problem is solved, I'll mark this as answer to close the thread.
Any what's more, you can just create new threads to ask new questions;)
Reguards!