I have this code below:
<select size="1" name="sel1">
<option value="c1">Choice 1</option>
<option value="c2">Choice 2</option>
<option value="c3">Choice 3</option>
<option value="c4">Choice 4</option>
</select>
Then what I want to happen, is to hide for example the 1st option in a method (for example below) in the .aspx.cs file. How to do that?
protected void RptFaqsAnswer_ItemDataBound(object sender, RepeaterItemEventArgs e){
// codes here...
}
Thanks
RJ
You have to use
runat=serverto make the code-behind aware of the HTML markup. There are two approaches you could take.Approach #1 Make the
selectan HTML server control.This will hide the option on the client side (ie, it still renders the HTML, just tells the browser not to display it).
Then you can modify the options however you like, eg:
Approach #2 Make the
optionelements server controls.This will not render the option to the client at all.
And set
Visibleto false in the code behind: