출처 : http://elvagood.egloos.com/tb/2385407

cs 에서 String(Javascript 배열) 만들어 내는 부분
List<VisitorDataInfo> visitorList = bllVisitorData.selectVisitorDataList(visitData.VisitDataCode.ToString());
for (int i = 0; i < visitorList.Count; i++)
{
VisitorDataInfo subVisitor = (VisitorDataInfo)visitorList[i];
reqVisitData = subVisitor.VisitDate;
arrVisitorList += "visitorCode[" + i + "]='" + subVisitor.VisitorInfo.VisitorCode + "';\n";
arrVisitorList += "visitorRegNumber[" + i + "]='" + subVisitor.VisitorInfo.VisitorRegNumber1 + "-" + subVisitor.VisitorInfo.VisitorRegNumber2 + "';\n";
arrVisitorList += "visitorName[" + i + "]='" + subVisitor.VisitorInfo.VisitorName + "';\n";
arrVisitorList += "companyName[" + i + "]='" + subVisitor.CompanyInfo.CompanyName + "';\n";
arrVisitorList += "phone[" + i + "]='" + subVisitor.VisitorInfo.VisitorPhone1 + "-" + subVisitor.VisitorInfo.VisitorPhone2 + "-" + subVisitor.VisitorInfo.VisitorPhone3 + "';\n";
}
aspx 에서 Data Binding 시키는 부분
<script language="javascript" type="text/javascript">
var visitorCode=new Array();
var visitorRegNumber=new Array();
var visitorName=new Array();
var companyName=new Array();
var phone=new Array();
var startDate=new Array();
var endDate=new Array();
<%=arrVisitorList%>
/*
visitorCode[0]='101010';
visitorRegNumber[0]='7-----';
visitorName[0]='ㅌㅌㅌㅌ';
companyName[0]="ㅌㅌㅌㅌㅌ";
phone[0]='016-435-3333';
startDate[0]='2007-02-03';
endDate[0]='2007-02-03';
*/
//로딩하면서 초기 화면에 뿌리기
function display(displayCellCount){
if(!displayCellCount) displayCellCount=defaultCellCount;
for(var cellCount=0;cellCount<displayCellCount;cellCount++){
insertRow();
}
}
function dataBind(){
var target=document.getElementById("visitorList");
for(var i=0;i<visitorCode.length+1;i++){
var rowCount=i+1;
if(visitorCode[i]){
target.rows[rowCount].cells[0].children[0].value=visitorCode[i];
target.rows[rowCount].cells[2].children[0].value=visitorRegNumber[i];
target.rows[rowCount].cells[3].children[0].value=visitorName[i];
target.rows[rowCount].cells[4].children[0].value=companyName[i];
target.rows[rowCount].cells[5].children[0].value=phone[i];
}
}
}
display(displayCellCount);
dataBind();
</script>

+ Recent posts