How do I init DropDownList in EditItemTemplate?

J

Jon J.

For a DataGrid with in-place editing, I have a databound DropDownList in one
column. How do I initialize it to a specific value? Is PreRender a good
event to use?

Here is the column code:

<asp:TemplateColumn HeaderText="Current Status">
<ItemTemplate>
<asp:Label ID="lblStatus" Text='<%#
Convert.ToString(DataBinder.Eval(Container.DataItem,"StatusName")) %>'
Runat="server"/>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList Runat="server" ID="editStatus" BackColor="#DDDDDD"
DataTextField="Name" DataValueField="ID" DataSource="<%#GetStatusValues() %>"
/>
</EditItemTemplate>
</asp:TemplateColumn>

Thanks
 
T

Teemu Keiski

In ItemDataBound event and when e.Item.ItemType is EditItem. You could
manually bind the ddl and then set the selected value.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,905
Latest member
Kristy_Poole

Latest Threads

Top