Kamran
Kamran

Reputation: 4100

Populate dropdownlist with data from sitecore to edit the item

Sorry for long description but it is necessary to describe my problem. I have made a web form where the staff can edit their detail. E.g Address Details.

So The data for editing is shown to the user using following code.

<p>Address</p>
<asp:TextBox runat="server" ID="txtBoxAdd"></asp:TextBox>
<p>City</p>
<asp:TextBox runat="server" ID="txtBoxCity"></asp:TextBox>
<p>Country</p>
 <asp:TextBox runat="server" ID="txtBoxCountry"></asp:TextBox>

BackEnd.

txtBoxAdd.Text = addressItem["address"];
txtBoxCity.Text = addressItem["city"];
txtBoxCountry.Text = addressItem["country"];

When the user clicks on Save Button, the item is put in editing mode. addressItem.Editing.BeginEdit(); And update the fields with the values in the text boxes.

Now The addressItem with the field country, addressItem["country"] is a dropdown in sitecore. With source as (the template for the addressItem): enter image description here

Is it possible that I show this drop down in the front end. filled with all the values from the sitecore.

What I am thinking is to make a dropdown list and add in it all the children of item /sitecore/content/Site Config/Constants/Countries. But I guess there could be a better solution?

Upvotes: 1

Views: 1759

Answers (1)

Anton
Anton

Reputation: 9961

Sitecore way: use Page(Experience) Editor. It is better to use this way, you'll get Sitecore benefits and development will be quicker and easier.

ASP.Net WebForms way: use DropDownList datasource. For example like here.

Upvotes: 0

Related Questions