ASP.NET 4x5 그리드에 멋진 확인란이있는 CheckboxList가있는 ASP.NET

StackOverflow https://stackoverflow.com/questions/1608501

  •  05-07-2019
  •  | 
  •  

문제

목록에 표시되는 CheckBoxList가 있습니다.

A
B
C
D

또는 수평

A B C D

이렇게 멋진 그리드로 배열하고 싶어요

A B C D
E F G H
I J K L

어떻게해야하나요?

도움이 되었습니까?

해결책

당신은 설정해야합니다 반복 방향 그리고 반복 컬럼 CheckBoxList의 속성.

<asp:CheckBoxList ID="myCheckBoxList" runat="server" 
     RepeatColumns="4" RepeatDirection="Horizontal">
 <asp:ListItem>A</asp:ListItem>
 <asp:ListItem>B</asp:ListItem> 
 <asp:ListItem>C</asp:ListItem>
 <asp:ListItem>D</asp:ListItem>
 <asp:ListItem>E</asp:ListItem>
 <asp:ListItem>F</asp:ListItem>
 <asp:ListItem>G</asp:ListItem>
 <asp:ListItem>H</asp:ListItem>
 <asp:ListItem>I</asp:ListItem>
 <asp:ListItem>J</asp:ListItem>
 <asp:ListItem>K</asp:ListItem>
 <asp:ListItem>L</asp:ListItem>
 <asp:ListItem>M</asp:ListItem>
 <asp:ListItem>N</asp:ListItem>
 <asp:ListItem>O</asp:ListItem>
 <asp:ListItem>P</asp:ListItem>
 <asp:ListItem>Q</asp:ListItem>
 <asp:ListItem>R</asp:ListItem>
 <asp:ListItem>S</asp:ListItem>
 <asp:ListItem>T</asp:ListItem>
</asp:CheckBoxList>

이렇게하면 4x5의 체크 박스 그리드가 렌더링됩니다.

A B C D
E F G H
I J K L
M N O P
Q R S T

다른 팁

글쎄, 당신의 아이템이 항상 정적 4x5 그리드에있을 경우, 당신은 아마도 직접 하드 코딩하는 것이 가장 좋습니다.

그렇지 않으면 데이터 소스와 같은 컨트롤을 사용하여 DataSource를 Just Check Box 컨트롤의 DL에 바인딩해야합니다. 데이터 목록의 좋은 점은 최소한 반복 열의 수와 반복 방향을 제어 할 수 있다는 것입니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top