1

I've got a container that has a few things. Of them, one is a button group with a drop down that is dynamically populated using C#.

This was working at one point, and then suddenly no longer works without any changes in the code.

Keep in mind, for the C# for-loop, I do get a "1" in the drop down, but I cannot drop down and choose any other number. I have another button object that presents the "tableCount", so I know the for-loop should increment to at least that number. I click the "V" (down arrow) and nothing is presented.

enter image description here

ASP.NET code snippet:

<div class="btn-group">
      <a href="#" id="AdminIndexSelect" runat="server" class="btn btn-default" style="height:25px; width:30px; padding:1px; text-align: center; vertical-align: middle;">-</a>
      <a href="#" class="btn btn-default dropdown-toggle" data-toggle="dropdown" style="height:25px; width:30px; padding:1px; text-align: center; vertical-align: middle;"><span class="caret"></span></a>
      <ul id ="AdminIndexDropDown" class="dropdown-menu" runat="server">
           <asp:Literal runat="server" id="AdminIndexDropDownList"></asp:Literal>
      </ul>
</div>

C# Snippet:

for(int i = 1 ; i <= tableCount ; i++){
    string  listText = "";
    listText += "<li role=\"presentation\">";
    listText += "<a role=\"menuitem\" tabindex=\"-1\" href=\"#\">";
    listText += i.ToString();
    listText += "</a></li>";
    AdminIndexDropDownList.Text += listText;
}
5
  • This code was originally sourced from: stackoverflow.com/questions/28544401/… Commented Feb 24, 2017 at 19:26
  • Just found this. Could this be a possibility? Commented Feb 24, 2017 at 21:24
  • I used some of that code for inspiration and somehow it started working. There wasn't really a difference between what I had and what was changed, but when I had put the CssClass="form-control" within the DropDownList attributes it started working but fell outside of its intended container. When I took it out, suddenly it started working. Other than the style elements now falling at the end of the list of attributes, I'm not sure what really fixed it, sadly. The article you posted was really good though and I am going to save that one for reference in the future. Thanks! Commented Feb 28, 2017 at 14:42
  • No problem you're welcome! Commented Feb 28, 2017 at 15:01
  • Okay, what had changed from the original posted code was the button group and the literal. No more button group, no literal, and I used what was provided in the link you had posted (which was very close to the direction I was taking, hence the confusion). My previous comment still stands, I just wanted to clear up that the solution was nothing like the code in the opening post. Thanks again, man! Commented Feb 28, 2017 at 18:40

1 Answer 1

1

Take a look at this code. It looks like what you're trying to do and it'll solve the issues you're having.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.