0
div id="Div1" class="myTeams">
     <div class="listTitle">My Teams</div>
    <div id="myTeams">
        <select id="myGroupList" name="myGroupList" onchange="reloadMYUser('myIntContacts');" size="10" />
<option value="abc_group"  selected >abc</option>
<option value="def_group" >def</option>
<option value="ghi_group" >ghi</option>
<option value="jkl_group" >jki</option>
 </select>

    </div>

i would like to search any group from the above list if it finds my group it should apply selected property for that list item. how can i do this from the codebehind?

  • To access the control from server side, it should have runat="server" attribute. – Amal Hashim Dec 2 '14 at 15:37
0

You can do something like this,

ListItem listItem = myGroupList.Items.FindByValue("def_group");

if (listItem != null)
{
    listItem.Selected = true;
};

You can modify it to pass a variable in first line, in place of "def_group".

  • thanks for your answer....unfortunately MyTeams is accessible from codebehind but i am unable to access myGroupList. – Rags Dec 3 '14 at 19:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.