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?

1
  • To access the control from server side, it should have runat="server" attribute. Dec 2, 2014 at 15:37

1 Answer 1

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".

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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