c# - Attribute is not updating using LINQ TO XML? -
i load xml file xelement. an element named r via:
xelement elem = xmltemplate.descendants().where(x => x.name.localname == "r").firstordefault(); i search attributes ef , ex via:
elem.attribute("ef").setvalue(txteffective.text); elem.attribute("ex").setvalue(txtexpire.text); but when call xtemplate.save(...), not save udpated attributes. have tried:
elem.attribute("ef").value = txteffective.text; elem.attribute("ex").value = txtexpire.text;
i found out problem, not sure how avoid it. when load xml, loading 2 attributes in 2 text boxes on form. when change values in text box update attributes, updating xml original values in text box , not new ones. wonder if has fact text boxes loaded on page load , when click button, loads xml again , overwrites new values original values. after did not load values in text box, save worked fine.
Comments
Post a Comment