ASP.NET CheckBoxList의 체크박스 리스트 사용시
값을 가져와 하나의 필드에 나중에 Split하여 사용하려고 문자열로 저장시
자동화 한 함수 입니다.
ASP.NET초보라 더 나은 방법이 있는데도 불구하고 함수를 만들어서 사용하는지도 모릅니다. -_-
-_- Visual Studio 6 만 사용하다가....
처음 2005로 개발하려고 클래스 리스트나 리소스등을 보고선 음 비슷하군... 하면서
Class Wizard( Ctrl + W) 를 눌렀는데... 클래스 위자드 가 안나와서
헉~ 클래스 위자드가 없어진겨? 하고는 한참이나 멤버변수나 함수등을 막코딩으로 작성하다가
맨붕(-0-)이 온적이 있는데... 요즘이 그상태 입니다. -_-;
------------------------------------------------------------------------------------------
private string fnGetJoinCheckBoxList(CheckBoxList CB)
{
string returnVAL = string.Empty;
foreach (ListItem li in CB.Items)
{
if (li.Selected)
{
returnVAL += li.Value + ",";
}
}
/*
if (returnVAL != string.Empty && Right(returnVAL, 1) == ",")
{
returnVAL = returnVAL.Substring(0, returnVAL.Length - 1);
}
*/
if(returnVAL != string.Empty)
{
returnVAL = returnVAL.Substring(0, returnVAL.Length - 1);
}
return returnVAL;
}
------------------------------------------------------------------------------------------
* 사용예
Response.Write(fnGetJoinCheckBoxList(this.CheckBoxList1));
*기타----------------------------
/*
private string Left(string Text, int TextLenth)
{
string ConvertText;
if(Text.Length < TextLenth)
{
TextLenth = Text.Length;
}
ConvertText = Text.Substring(0, TextLenth);
return ConvertText;
}
private string Right(string Text, int TextLenth)
{
string ConvertText;
if (Text.Length < TextLenth)
{
TextLenth = Text.Length;
}
ConvertText = Text.Substring(Text.Length - TextLenth, TextLenth);
return ConvertText;
}
private string Mid(string Text,int Startint, int Endint)
{
string ConvertText;
if (Startint < Text.Length || Endint < Text.Length)
{
ConvertText = Text.Substring(Startint, Endint);
return ConvertText;
}
else
{
return Text;
}
}
*/