Hello guys,
i have "UserProfile" in my site which we have stored in xml
fromat of xml is as below
<UserProfile xmlns="">
<BasicInfo>
<Title value="Basic Details" />
<Fields>
<UserId title="UserId" display="No" right="Public" value="12" />
<EmailAddress title="Email Address" display="Yes" right="Public" value="
[email protected]" />
<FirstName title="First Name" display="Yes" right="Public" value="Radhi" />
<LastName title="Last Name" display="Yes" right="Public" value="Patel" />
<DisplayName title="Display Name" display="Yes" right="Public" value="Radhi Patel" />
<RegistrationStatusId title="RegistrationStatusId" display="No" right="Public" value="10" />
<RegistrationStatus title="Registration Status" display="Yes" right="Private" value="Registered" />
<CountryName title="Country" display="Yes" right="Public" value="India" />
<StateName title="State" display="Yes" right="Public" value="Maharashtra" />
<CityName title="City" display="Yes" right="Public" value="Mumbai" />
<Gender title="Gender" display="Yes" right="Public" value="FeMale" />
<CreatedBy title="CreatedBy" display="No" right="Public" value="0" />
<CreatedOn title="CreatedOn" display="No" right="Public" value="Nov 27 2009 3:08PM " />
<ModifiedBy title="ModifiedBy" display="No" right="Public" value="12" />
<ModifiedOn title="ModifiedOn" display="No" right="Public" value="Feb 18 2010 1:43PM " />
<LogInStatusId title="LogInStatusId" display="No" right="Public" value="1" />
<LogInStatus title="LogIn Status" display="Yes" right="Private" value="Free" />
<ProfileImagePath title="Profile Pic" display="No" right="Public" value="~/Images/96.jpg" />
</Fields>
</BasicInfo>
<PersonalInfo>
<Title value="Personal Details" />
<Fields>
<Nickname title="Nick Name" display="Yes" right="Public" value="Rahul" />
<NativeLocation title="Native" display="Yes" right="Public" value="Amreli" />
<DateofAnniversary title="Anniversary Dt." display="Yes" right="Public" value="12/29/2008" />
<BloodGroupId title="BloodGroupId" display="No" right="Public" value="25" />
<BloodGroupName title="Blood Group" display="Yes" right="Public" value="25" />
<MaritalStatusId title="MaritalStatusId" display="No" right="Public" value="34" />
<MaritalStatusName title="Marital status" display="Yes" right="Private" value="34" />
<DateofDeath title="Death dt" display="Yes" right="Private" value="" />
<CreatedBy title="CreatedBy" display="No" right="Public" value="12" />
<CreatedOn title="CreatedOn" display="No" right="Public" value="Jan 6 2010 2:59PM " />
<ModifiedBy title="ModifiedBy" display="No" right="Public" value="12" />
<ModifiedOn title="ModifiedOn" display="No" right="Public" value="3/10/2010 5:34:14 PM" />
</Fields>
</PersonalInfo>
<FamilyInfo>
<Title value="Family Details" />
<Fields>
<GallantryHistory title="Gallantry History" display="Yes" right="Public" value="Gallantry history rahul" />
<Ethinicity title="Ethinicity" display="Yes" right="Public" value="ethnicity rahul" />
<KulDev title="KulDev" display="Yes" right="Public" value="Krishna" />
<KulDevi title="KulDevi" display="Yes" right="Public" value="Khodiyar" />
<Caste title="Caste" display="Yes" right="Private" value="Brhamin" />
<SunSignId title="SunSignId" display="No" right="Public" value="20" />
<SunSignName title="SunSignName" display="Yes" right="Public" value="
Scorpio" />
<CreatedBy title="CreatedBy" display="No" right="Public" value="12" />
<CreatedOn title="CreatedOn" display="No" right="Public" value="Dec 29 2009 4:59PM " />
<ModifiedBy title="ModifiedBy" display="No" right="Public" value="12" />
<ModifiedOn title="ModifiedOn" display="No" right="Public" value="3/10/2010 6:29:56 PM" />
</Fields>
</FamilyInfo>
<HobbyInfo>
<Title value="Hobbies/Interests" />
<Fields>
<AbountMe title="Abount Me" display="Yes" right="Public" value="Naughty.... " />
<Hobbies title="Hobbies" display="Yes" right="Public" value="Dance, Music, decoration, Shopping" />
<Food title="Food" display="Yes" right="Public" value="Maxican salsa, Pizza, Khoya kaju " />
<Movies title="Movies" display="Yes" right="Public" value="day after tommorrow. wake up sid. avatar" />
<Music title="Music" display="Yes" right="Public" value="Chu kar mere man ko... wake up sid songs, slow music, apgk songs" />
<TVShows title="TV Shows" display="Yes" right="Public" value="business bazzigar, hanah montana" />
<Books title="Books" display="Yes" right="Public" value="mystry novels" />
<Sports title="Sports" display="Yes" right="Public" value="Badminton" />
<Will title="Will" display="Yes" right="Public" value="do photography, to have my own super home... and i can decorate it like anything..." />
<FavouriteQuotes title="Favourite Quotes" display="Yes" right="Public" value="Live like a king nothing lasts forever. not even your troubles smooth sea do not makes skillfull sailors" />
<CremationPrefernces title="Cremation Prefernces" display="Yes" right="Public" value="" />
<CreatedBy title="CreatedBy" display="No" right="Public" value="12" />
<CreatedOn title="CreatedOn" display="No" right="Public" value="Feb 24 2010 2:13PM " />
<ModifiedBy title="ModifiedBy" display="No" right="Public" value="12" />
<ModifiedOn title="ModifiedOn" display="No" right="Public" value="Mar 2 2010 4:34PM " />
</Fields>
</HobbyInfo>
<PermenantAddr>
<Title value="Permenant Address" />
<Fields>
<Address title="Address" display="Yes" right="Public" value="Test Entry" />
<CityId title="CityId" display="No" right="Public" value="93" />
<CityName title="City" display="Yes" right="Public" value="Chennai" />
<StateId title="StateId" display="No" right="Public" value="89" />
<StateName title="State" display="Yes" right="Public" value="Tamil Nadu" />
<CountryId title="CountryId" display="No" right="Public" value="108" />
<CountryName title="Country" display="Yes" right="Public" value="India" />
<ZipCode title="ZipCode" display="Yes" right="Private" value="360019" />
<CreatedBy title="CreatedBy" display="No" right="Public" value="12" />
<CreatedOn title="CreatedOn" display="No" right="Public" value="Jan 6 2010 1:29PM " />
<ModifiedBy title="ModifiedBy" display="No" right="Public" value="0" />
<ModifiedOn title="ModifiedOn" display="No" right="Public" value=" " />
</Fields>
</PermenantAddr>
<PresentAddr>
<Title value="Present Address" />
<Fields>
<Address title="Ethinicity" display="Yes" right="Public" value="" />
<CityId title="CityId" display="No" right="Public" value="" />
<CityName title="City" display="Yes" right="Public" value="" />
<StateId title="StateId" display="No" right="Public" value="" />
<StateName title="State" display="Yes" right="Public" value="" />
<CountryId title="CountryId" display="No" right="Public" value="" />
<CountryName title="Country" display="Yes" right="Public" value="" />
<ZipCode title="ZipCode" display="Yes" right="Public" value="" />
<CreatedBy title="CreatedBy" display="No" right="Public" value="" />
<CreatedOn title="CreatedOn" display="No" right="Public" value="" />
<ModifiedBy title="ModifiedBy" display="No" right="Public" value="" />
<ModifiedOn title="ModifiedOn" display="No" right="Public" value="" />
</Fields>
</PresentAddr>
<ContactInfo>
<Title value="Contact Details" />
<Fields>
<DayPhoneNo title="Day Phone" display="Yes" right="Public" value="" />
<NightPhoneNo title="Night Phone" display="Yes" right="Public" value="" />
<MobileNo title="Mobile No" display="Yes" right="Private" value="" />
<FaxNo title="Fax No" display="Yes" right="CUG" value="" />
<CreatedBy title="CreatedBy" display="No" right="Public" value="12" />
<CreatedOn title="CreatedOn" display="No" right="Public" value="Jan 5 2010 12:37PM " />
<ModifiedBy title="ModifiedBy" display="No" right="Public" value="12" />
<ModifiedOn title="ModifiedOn" display="No" right="Public" value="Feb 17 2010 1:37PM " />
</Fields>
</ContactInfo>
<EmailInfo>
<Title value="Alternate Email Addresses" />
<Fields />
</EmailInfo>
<AcademicInfo>
<Title value="Education Details" />
<Fields>
<Record right="Public">
<Education title="Education" display="Yes" value="Full Attendance" />
<Institute title="Institute" display="Yes" value="Attendance" />
<PassingYear title="Passing Year" display="Yes" value="2000" />
<IsActive title="IsActive" display="No" value="false" />
<CreatedBy title="CreatedBy" display="No" value="12" />
<CreatedOn title="CreatedOn" display="No" value="Dec 31 2009 12:41PM " />
<ModifiedBy title="ModifiedBy" display="No" value="12" />
<ModifiedOn title="ModifiedOn" display="No" value="Dec 31 2009 12:41PM " />
</Record>
<Record right="Public">
<Education title="Education" display="Yes" value="D.C.E." />
<Institute title="Institute" display="Yes" value="G.P.G" />
<PassingYear title="Passing Year" display="Yes" value="2005" />
<IsActive title="IsActive" display="No" value="true" />
<CreatedBy title="CreatedBy" display="No" value="12" />
<CreatedOn title="CreatedOn" display="No" value="Dec 31 2009 12:45PM " />
<ModifiedBy title="ModifiedBy" display="No" value="12" />
<ModifiedOn title="ModifiedOn" display="No" value="Dec 31 2009 12:45PM " />
</Record>
<Record right="Public">
<Education title="Education" display="Yes" value="MCSE" />
<Institute title="Institute" display="Yes" value="MCSE" />
<PassingYear title="Passing Year" display="Yes" value="2009" />
<IsActive title="IsActive" display="No" value="true" />
<CreatedBy title="CreatedBy" display="No" value="12" />
<CreatedOn title="CreatedOn" display="No" value="Dec 31 2009 6:12PM " />
<ModifiedBy title="ModifiedBy" display="No" value="12" />
<ModifiedOn title="ModifiedOn" display="No" value="Mar 2 2010 4:33PM " />
</Record>
<Record right="Public">
<Education title="Education" display="Yes" value="H.S.C." />
<Institute title="Institute" display="Yes" value="G.H.S.E.B." />
<PassingYear title="Passing Year" display="Yes" value="2002" />
<IsActive title="IsActive" display="No" value="true" />
<CreatedBy title="CreatedBy" display="No" value="12" />
<CreatedOn title="CreatedOn" display="No" value="Dec 31 2009 6:17PM " />
<ModifiedBy title="ModifiedBy" display="No" value="12" />
<ModifiedOn title="ModifiedOn" display="No" value="Dec 31 2009 6:17PM " />
</Record>
<Record right="Public">
<Education title="Education" display="Yes" value="S.S.C." />
<Institute title="Institute" display="Yes" value="G.S.E.B." />
<PassingYear title="Passing Year" display="Yes" value="2000" />
<IsActive title="IsActive" display="No" value="true" />
<CreatedBy title="CreatedBy" display="No" value="12" />
<CreatedOn title="CreatedOn" display="No" value="Dec 31 2009 6:17PM " />
<ModifiedBy title="ModifiedBy" display="No" value="12" />
<ModifiedOn title="ModifiedOn" display="No" value="Dec 31 2009 6:17PM " />
</Record>
</Fields>
</AcademicInfo>
<AchievementInfo>
<Title value="Achievement Details" />
<Fields>
<Record right="Public">
<Awards title="Award" display="Yes" value="Test Entry" />
<FieldOfAward title="Field Of Award" display="Yes" value="Test Entry" />
<Tournament title="Tournament" display="Yes" value="Test Entry" />
<AwardDescription title="Description" display="Yes" value="Test Entry" />
<AwardYear title="Award Year" display="Yes" value="2002" />
<IsActive title="IsActive" display="No" value="true" />
<CreatedBy title="CreatedBy" display="No" value="12" />
<CreatedOn title="CreatedOn" display="No" value="Dec 31 2009 3:51PM " />
<ModifiedBy title="ModifiedBy" display="No" value="12" />
<ModifiedOn title="ModifiedOn" display="No" value="Dec 31 2009 3:51PM " />
</Record>
<Record right="Public">
<Awards title="Award" display="Yes" value="Test Entry" />
<FieldOfAward title="Field Of Award" display="Yes" value="Test Entry" />
<Tournament title="Tournament" display="Yes" value="Test Entry" />
<AwardDescription title="Description" display="Yes" value="Test Entry" />
<AwardYear title="Award Year" display="Yes" value="2005" />
<IsActive title="IsActive" display="No" value="true" />
<CreatedBy title="CreatedBy" display="No" value="12" />
<CreatedOn title="CreatedOn" display="No" value="Jan 8 2010 10:19AM " />
<ModifiedBy title="ModifiedBy" display="No" value="12" />
<ModifiedOn title="ModifiedOn" display="No" value="Jan 8 2010 10:19AM " />
</Record>
<Record right="Public">
<Awards title="Award" display="Yes" value="Test Entry3" />
<FieldOfAward title="Field Of Award" display="Yes" value="Test Entry3" />
<Tournament title="Tournament" display="Yes" value="Test Entry3" />
<AwardDescription title="Description" display="Yes" value="Test Entry3" />
<AwardYear title="Award Year" display="Yes" value="2007" />
<IsActive title="IsActive" display="No" value="true" />
<CreatedBy title="CreatedBy" display="No" value="12" />
<CreatedOn title="CreatedOn" display="No" value="Dec 31 2009 11:47AM " />
<ModifiedBy title="ModifiedBy" display="No" value="12" />
<ModifiedOn title="ModifiedOn" display="No" value="Dec 31 2009 11:47AM " />
</Record>
<Record right="Public">
<Awards title="Award" display="Yes" value="Test Entry4" />
<FieldOfAward title="Field Of Award" display="Yes" value="Test Entry4" />
<Tournament title="Tournament" display="Yes" value="Test Entry4" />
<AwardDescription title="Description" display="Yes" value="Test Entry3" />
<AwardYear title="Award Year" display="Yes" value="2000" />
<IsActive title="IsActive" display="No" value="false" />
<CreatedBy title="CreatedBy" display="No" value="12" />
<CreatedOn title="CreatedOn" display="No" value="Dec 31 2009 11:47AM " />
<ModifiedBy title="ModifiedBy" display="No" value="12" />
<ModifiedOn title="ModifiedOn" display="No" value="Dec 31 2009 11:47AM " />
</Record>
</Fields>
</AchievementInfo>
<ProfessionalInfo>
<Title value="Professional Details" />
<Fields>
<Record right="Public">
<Occupation title="Occupation" display="Yes" value="Test Entry" />
<Organization title="Organization" display="Yes" value="Test Entry" />
<ProjectsDescription title="Description" display="Yes" value="Test Entry" />
<Duration title="Duration" display="Yes" value="26" />
<IsActive title="IsActive" display="No" value="false" />
<CreatedBy title="CreatedBy" display="No" value="12" />
<CreatedOn title="CreatedOn" display="No" value="Jan 4 2010 3:01PM " />
<ModifiedBy title="ModifiedBy" display="No" value="12" />
<ModifiedOn title="ModifiedOn" display="No" value="Jan 4 2010 3:01PM " />
</Record>
<Record right="Public">
<Occupation title="Occupation" display="Yes" value="Test Entry" />
<Organization title="Organization" display="Yes" value="Test Entry" />
<ProjectsDescription title="Description" display="Yes" value="Test Entry" />
<Duration title="Duration" display="Yes" value="10" />
<IsActive title="IsActive" display="No" value="false" />
<CreatedBy title="CreatedBy" display="No" value="12" />
<CreatedOn title="CreatedOn" display="No" value="Jan 4 2010 3:01PM " />
<ModifiedBy title="ModifiedBy" display="No" value="12" />
<ModifiedOn title="ModifiedOn" display="No" value="Jan 4 2010 3:01PM " />
</Record>
<Record right="Public">
<Occupation title="Occupation" display="Yes" value="Test Entry" />
<Organization title="Organization" display="Yes" value="Test Entry" />
<ProjectsDescription title="Description" display="Yes" value="Test Entry" />
<Duration title="Duration" display="Yes" value="15" />
<IsActive title="IsActive" display="No" value="false" />
<CreatedBy title="CreatedBy" display="No" value="12" />
<CreatedOn title="CreatedOn" display="No" value="Jan 4 2010 3:01PM " />
<ModifiedBy title="ModifiedBy" display="No" value="12" />
<ModifiedOn title="ModifiedOn" display="No" value="Jan 4 2010 3:01PM " />
</Record>
</Fields>
</ProfessionalInfo>
</UserProfile>
now for tags like PersonalInfo,contactInfo,Address there will be only one record, but for tags like "OtherInfo","academicInfo","ProfessionalInfo" there will be multiple records so in xml there are tags for that.
now to edit tags having one record only for one user i did coding like:
private void FillFamilyInfoControls(XElement rootElement) { ddlSunsign.DataBind(); XElement parentElement; string xPathQuery = "FamilyInfo/Fields"; parentElement
= rootElement.XPathSelectElement(xPathQuery); txtGallantryHistory.Text = parentElement.Element("GallantryHistory").Attribute("value").Value; txtEthinicity.Text = parentElement.Element("Ethinicity").Attribute("value").Value; txtKulDev.Text = parentElement.Element("KulDev").Attribute("value").Value; txtKulDevi.Text = parentElement.Element("KulDevi").Attribute("value").Value; txtCaste.Text = parentElement.Element("Caste").Attribute("value").Value; ddlSunsign.SelectedValue = parentElement.Element("SunSignId").Attribute("value").Value; ddlSunsign.SelectedItem.Text = parentElement.Element("SunSignName").Attribute("value").Value; } private XElement UpdateFamilyInfoXML(XElement rootElement) { XElement parentElement; string xPathQuery = "FamilyInfo/Fields"; parentElement
= rootElement.XPathSelectElement(xPathQuery); parentElement.Element("GallantryHistory").Attribute("value").Value
= txtGallantryHistory.Text; parentElement.Element("Ethinicity").Attribute("value").Value
= txtEthinicity.Text; parentElement.Element("KulDev").Attribute("value").Value
= txtKulDev.Text; parentElement.Element("KulDevi").Attribute("value").Value
= txtKulDevi.Text; parentElement.Element("Caste").Attribute("value").Value
= txtCaste.Text; parentElement.Element("SunSignId").Attribute("value").Value
= ddlSunsign.SelectedItem.Value; parentElement.Element("SunSignName").Attribute("value").Value
= ddlSunsign.SelectedItem.Text; parentElement.Element("ModifiedBy").Attribute("value").Value
= UMSession.CurrentLoggedInUser.UserId.ToString(); parentElement.Element("ModifiedOn").Attribute("value").Value
= System.DateTime.Now.ToString(); return rootElement; //rootElement.XPathSelectElement(xPathQuery)
= parentElement; }
these 2 functions i have used to update xml and to get data from xml and fill into controls.
but for the tags where there are multiple records... i am not able to find any solution /control using which i an do it easily.
coz my field's value is in attribute named "Value" when in the examples i saw its between opening and closing tag..
i have 2 methods to do so.
1
. i make one page to edit a single record and pass id of record to that page on editing.
open the page in iframe on same page to edit and in page_load get data from database for id passed and fill it in control.
2
. i store xml on server as physical file and use it in page i opened in iframe to edit the record.
so i am confused... can anybody please guide me that what shpould i do to let user provide interface to edit this xml data/user profile ?