Control inside repeater row ASP.NET

Hello All

Few days back I was struggling with a repeater problem , where I have to get a value of dropdown list on a button click event which is inside repeater. Eventually I come up with a solution through googling. What I have faced was get the value of appropriate dropdown list while clicking the button of a particular repeater’s row.

It’s being hard to describe rather that visualize :) isn’t it ! ( proposed solution should be as image bellow)

My aspx markup is as bellow :

And my code behind file is as bellow :

Not all codes are important here and I will escape the data binding part as its not the focus of today’s topic. Now I will focus what we should do to perform our basic task.

first of all we have to do one most important  thing *** MAKE
EnableViewState="false" *** If ViewState is in true condition your are not going to handle  OnItemCommand event which will significantly react for your particular row’s activity.

<asp:Repeater runat=”server” ID=”rptTeamInfo” OnItemDataBound=”rptTeamInfo_ItemDataBound” OnItemCommand=”rptTeamInfo_ItemCommand”>


<asp:ImageButton id=”imgAddToTeam” CommandName=”select” CommandArgument=’<%# Eval(“team_id”) %>ImageUrl=”images/Add_to_team.png” runat=”server” style=”margin:10px;” align=”right”></asp:ImageButton>

<asp:DropDownList ID=”ddlUserList” runat=”server”>




The event handler “rptTeamInfo_ItemCommand” for the the event “OnItemCommand” is as bellow.

We are passing the “CommandName” and “CommandArgument” through our image button which will check the command name in code behind and act with the command argument parameter.

We can get our ImageButton and DropdownList is as bellow from our code behind.

And selet the value of dropdown as bellow.

In this way we can accomplish our task regarding the repeater row’s control manipulation.

Thats all for today.