So here\'s the situation. I have a dropdownlist in a repeater that is inside a formview.
And the really special part is that the repeater is being used to add multiple r
If the value cant be set just int the drodownlist tag like...
SelectedValue='<%# Eval("ColumnWithValue")%>'
... then you need to work with OnItemDataBound
Basically:
On repeater tag, add this attribute:
OnItemDataBound="FormatRepeaterRow"
On page code-behind:
protected void FormatRepeaterRow(Object sender, RepeaterItemEventArgs e)
{
if( (e.Item.ItemType == ListItemType.Item) || ( e.Item.ItemType == ListItemType.AlternatingItem))
{
((DropDownList)e.Item.FindControl("ddlType")).SelectedValue = "a_value";
}
}
you can bind the SelectedValue property of Dropdown in your markup page i.e
<asp:DropDownList ID="ddlType" runat="server" DataSourceID="SqlDataSource26"
DataTextField="tt_type" DataValueField="tt_id"
SelectedValue='<%# Eval("ColumnName")%>'>
</asp:DropDownList>
Hope, this will fix your problem.