Rameez says:
drpfs.Items.FindByValue(13).Selected =
True
FindByValue accepts parameter of string type.
Refer the below sample.
I have the databse table for binding the repeater and dropdownlist like below.

HTML
<asp:Repeater ID="rptCustomers" runat="server" OnItemDataBound="ItemDataBound">
<HeaderTemplate>
<table>
<tr>
<th>
Customer Id
</th>
<th>
Customer Name
</th>
<th>
Country
</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<asp:Label ID="lblCustomerId" runat="server" Text='<%# Eval("CustomerId") %>' />
</td>
<td>
<asp:Label ID="lblContactName" runat="server" Text='<%# Eval("Name") %>' />
</td>
<td>
<asp:DropDownList runat="server" ID="ddlCountry">
</asp:DropDownList>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
this.BindRepeater();
}
}
private void BindRepeater()
{
string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand("SELECT TOP 5 * FROM Customers", con))
{
using (SqlDataAdapter sda = new SqlDataAdapter(cmd))
{
cmd.CommandType = CommandType.Text;
DataTable dt = new DataTable();
sda.Fill(dt);
rptCustomers.DataSource = dt;
rptCustomers.DataBind();
}
}
}
}
private void PopulateDropDownList(DropDownList ddl, string dataTextField, string dataValueField, string query)
{
string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand(query, con))
{
using (SqlDataAdapter da = new SqlDataAdapter(cmd))
{
con.Open();
DataSet ds = new DataSet();
da.Fill(ds);
ddl.DataTextField = dataTextField;
ddl.DataValueField = dataValueField;
ddl.DataSource = ds;
ddl.DataBind();
ddl.Items.Insert(0, new System.Web.UI.WebControls.ListItem("Please Select", "0"));
}
}
}
}
protected void ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
DropDownList country = e.Item.FindControl("ddlCountry") as DropDownList;
PopulateDropDownList(country, "CountryName", "CountryID", "SELECT CountryID,CountryName FROM Country");
country.Items.Insert(0, new ListItem("----Select Location----", "0"));
country.Items.FindByValue("5").Selected = true;
}
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not Me.IsPostBack Then
Me.BindRepeater()
End If
End Sub
Private Sub BindRepeater()
Dim constr As String = ConfigurationManager.ConnectionStrings("constr").ConnectionString
Using con As SqlConnection = New SqlConnection(constr)
Using cmd As SqlCommand = New SqlCommand("SELECT TOP 5 * FROM Customers", con)
Using sda As SqlDataAdapter = New SqlDataAdapter(cmd)
cmd.CommandType = CommandType.Text
Dim dt As DataTable = New DataTable()
sda.Fill(dt)
rptCustomers.DataSource = dt
rptCustomers.DataBind()
End Using
End Using
End Using
End Sub
Private Sub PopulateDropDownList(ByVal ddl As DropDownList, ByVal dataTextField As String, ByVal dataValueField As String, ByVal query As String)
Dim constr As String = ConfigurationManager.ConnectionStrings("constr").ConnectionString
Using con As SqlConnection = New SqlConnection(constr)
Using cmd As SqlCommand = New SqlCommand(query, con)
Using da As SqlDataAdapter = New SqlDataAdapter(cmd)
con.Open()
Dim ds As DataSet = New DataSet()
da.Fill(ds)
ddl.DataTextField = dataTextField
ddl.DataValueField = dataValueField
ddl.DataSource = ds
ddl.DataBind()
ddl.Items.Insert(0, New System.Web.UI.WebControls.ListItem("Please Select", "0"))
End Using
End Using
End Using
End Sub
Protected Sub ItemDataBound(ByVal sender As Object, ByVal e As RepeaterItemEventArgs)
If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType = ListItemType.AlternatingItem Then
Dim country As DropDownList = TryCast(e.Item.FindControl("ddlCountry"), DropDownList)
PopulateDropDownList(country, "CountryName", "CountryID", "SELECT CountryID,CountryName FROM Country")
country.Items.Insert(0, New ListItem("----Select Location----", "0"))
country.Items.FindByValue("5").Selected = True
End If
End Sub
Output
