2009. 6. 21. 15:36

업종별 표준 업무 프로세스 모델


중소기업기술정보진흥원에서는 전통산업의 e-Manufacturing 및 e-Industry를 촉진하기 위해 업종별로 생산 방식 및 경영형태가 유사한 분야의 업무 프로세스를 표준화하여 2001년도부터 3년동안 총 20개 업종에 대한 표준모델을 개발하여 업종별 업무프로세스 표준모델을 제공하고 있습니다.

◆ 업종별 표준 업무 프로세스 모델

-1차년도 원문보기
  통신기기/방송장비
  반도체/전자부품
  전기기계
  자동차 부품
  식품 가공
  의약품/화학

-2차년도 원문보기
  고무/플라스틱 제조업
  제1차 금속산업
  조립금속 제품 제조업
  일반기계
  특수기계
  공통(인사/회계)

-3차년도 원문보기
  컴퓨터/사무기기 제조업
  선박 및 보트 제조업
  석유 정제품
  봉제/의복 제조업
  골판지/종이 제조업
  기초 화합물 제조업
  물류 서비스업
  제과 제조업
  유통 서비스업
  공통(인사/회계)

◆ 표준모델 적용 방법론
    중소기업기술정보진흥원에서 프로세스 모델을 도출하기 위하여 사용된 연차별
    프로세스 모델링 방법론
    - 1차년도 적용 방법론
    - 2차년도 적용 방법론
    - 3차년도 적용 방법론
    - 웹 개발 방법론


2009. 5. 21. 10:11

Creating interactive alert, confirm, and prompt boxes using JavaScript

출처 : Creating interactive alert, confirm, and prompt boxes using JavaScript

  The alert, confirm, and prompt boxes

The three "commands" involved in creating alert, confirm, and prompt boxes are:

  • window.alert()
  • window.confirm()
  • window.prompt()

Lets look at them in detail. The first one is:

window.alert()

This command pops up a message box displaying whatever you put in it. For example:

<body>
    <script type="text/javascript">
    window.alert("My name is George. Welcome!")
    </script>
</body>
        

As you can see, whatever you put inside the quotation marks, it will display it.

The second one is:

window.confirm()

Confirm is used to confirm a user about certain action, and decide between two choices depending on what the user chooses.

Click here for output: 

<script type="text/javascript">
    var x=window.confirm("Are you sure you are ok?")
    if (x)
    window.alert("Good!")
    else
    window.alert("Too bad")
</script>

There are several concepts that are new here, and I'll go over them. First of all, "var x=" is a variable declaration; it declares a variable ("x" in this case) that will store the result of the confirm box. All variables are created this way. x will get the result, namely, "true" or "false". Then we use a "if else" statement to give the script the ability to choose between two paths, depending on this result. If the result is true (the user clicked "ok"), "good" is alerted. If the result is false (the user clicked "cancel"), "Too bad" is alerted instead. (For all those interested, variable x is called a Boolean variable, since it can only contain either a value of "true" or "false").

The third one is:

window.prompt()

Prompt is used to allow a user to enter something, and do something with that info:

Click here for output: 

<script type="text/javascript">
    var y=window.prompt("please enter your name")
    window.alert(y)
</script>
            

The concept here is very similar. Store whatever the user typed in the prompt box using y. Then display it.

2009. 5. 20. 10:16

Checking / UnChecking all checkboxes of the page dynamically in a single click

출처 : http://www.dotnetfunda.com/articles/article85.aspx

화면 상의 모든 체크 박스를 단일 클릭으로 모두 Checking, UnChecking 하는 JavaScript
Introduction

Generally we came acroos in this situation when we need to facilitate the user to select or delsect all records of the page at a single click instead of selecting records one by one.  You can refer to below picture for example.

Scenario

This generally happens when you are presenting some records into GridView or DataGrid and you are providing a column called Select, instead of checking all records one by one you want to provide links called "Select All" or  "DeSelect All" to check and uncheck all checkboxes of the GridView respectively.  

Solution

HTML Code

To do that you need to provide a two links as displayed in the picture above. Following is the code for "Select All" and "DeSelect All" link.

 

<a href="javascript:void(0)" onclick="SelectAllCheckBoxes(true)">Select All</a> | <a href="javascript:void(0)" onclick="SelectAllCheckBoxes(false)">DeSelect All</a>

If Select All link will be clicked then SelectAllCheckBoxes javascript function will fire with parameter as true and when DeSelect All link will be clicked the same function will fire with paramter as false.

JavaScript Code

The code for JavaScript function SelectAllCheckBoxes are as follows

<script language="javascript" type="text/javascript">

function SelectAllCheckBoxes(action)

{

var myform=document.forms['aspnetForm'];

var len = myform.elements.length;

   for( var i=0 ; i < len ; i++)

   {

   if (myform.elements[i].type == 'checkbox')

      myform.elements[i].checked = action;

   }

}

</script>

In the above function first I am getting the html form element in the myform variables then I am getting the length of all elements on the page. Next I am looping through all the elements and checking for the element whose element type is checkbox as I am only interested about the checkbox element of the page. Once I got the checkbox element I am assiging the checked property to the parameter passed to this function (either true or false) and I am done.

Thats it!!!

Conclusion

Doing this was simpler than I had expected, hope this helps some one. Thanks and Happy Coding !!!

2009. 5. 20. 08:34

javacript 로 만든 달력 샘플

출처 : daum 지난 경기 보기에서 가져와서 조금 고침.

<html>
<head>
<title>
</title>
</head>
<style type="text/css">
a.topmenus {color:#031d6a;font-size:12px;font-weight:bold;text-decoration:none;}
a.topmenus:link{color:#031d6a;font-size:12px;font-weight:bold;text-decoration:none;}
a.topmenus:visited{color:#031d6a;font-size:12px;font-weight:bold;text-decoration:none}
a.topmenus:active{color:#031d6a;font-size:12px;font-weight:bold;text-decoration:underline}
a.topmenus:hover{color:#031d6a;font-size:12px;font-weight:bold;text-decoration:underline}

#gnb_layer_opacity {position:relative; float:left; background-color:#658cff; filter:alpha(opacity=30); -moz-opacity:0.3; display:none;}
:root .gnb_news_opacity {float:left; top:-72px; left:49px; width:69px; height:28px; z-index:1000;}
:root .gnb_sports_opacity {float:left; top:-72px; left:137px; width:73px; height:28px; z-index:1000;}
:root .gnb_tvnews_opacity {float:left; top:-72px; left:232px; width:113px; height:28px; z-index:1000;}
:root .gnb_sisa_opacity {float:left; top:-72px; left:362px; width:109px; height:28px; z-index:1000;}
:root .gnb_issue_opacity {float:left; top:-72px; left:496px; width:107px; height:28px; z-index:1000;}
:root .gnb_photo_opacity {float:left; top:-72px; left:624px; width:70px; height:28px; z-index:1000;}
:root .gnb_reporter_opacity {float:left; top:-72px; left:713px; width:107px; height:28px; z-index:1000;}
:root .gnb_weather_opacity {float:left; top:-72px; left:842px; width:69px; height:28px; z-index:1000;}
:root .gnb_menu_opacity {position:relative; float:left; margin:0; top:-20px; left:0; width:960px; height:18px; overflow:hidden; display:inline;}
* html .gnb_news_opacity {float:left; top:-76px; left:49px; width:69px; height:28px; z-index:1000;}
* html .gnb_sports_opacity {float:left; top:-76px; left:137px; width:73px; height:28px; z-index:1000;}
* html .gnb_tvnews_opacity {float:left; top:-76px; left:232px; width:113px; height:28px; z-index:1000;}
* html .gnb_sisa_opacity {float:left; top:-76px; left:362px; width:109px; height:28px; z-index:1000;}
* html .gnb_issue_opacity {float:left; top:-76px; left:496px; width:107px; height:28px; z-index:1000;}
* html .gnb_photo_opacity {float:left; top:-76px; left:624px; width:70px; height:28px; z-index:1000;}
* html .gnb_reporter_opacity {float:left; top:-76px; left:713px; width:107px; height:28px; z-index:1000;}
* html .gnb_weather_opacity {float:left; top:-76px; left:842px; width:69px; height:28px; z-index:1000;}
* html .gnb_menu_opacity {position:relative; float:left; margin:0; top:-24px; left:0; width:960px; height:18px; overflow:hidden;}
</style>
<!--달력 -->
<script language="JavaScript" type="text/JavaScript">
//오늘 날짜 설정
datToday = new Date();

//현재 년월일
NowThisYear = datToday.getFullYear();
NowThisMonth = datToday.getMonth()+1;
NowThisDay = datToday.getDate();


//날자를 선택하였을 경우
function doClick(sYear, sMonth, sDay)
{
var broad_dt = sYear + (sMonth<10?'0':'') + sMonth + (sDay<10?'0':'') + sDay;
document.location.href = '/exec/program/prog_main.php?prog_id=01&broad_dt='+broad_dt;
}

//2자리 숫자로 변경
function day2(sd)
{
var intd = new Number();
intd = parseInt(sd);

var str = new String();
if(intd < 10) {
str = "0" + intd;
} else {
str = "" + intd;
}
return str;
}

//년 정보를 콤보 박스로 표시
function getYearinfo(sYear, sMonth)
{
var intYear = new Number();
intYear = parseInt(sYear);

var min = 2000;
var max = (intYear > NowThisYear) ? intYear : NowThisYear;

var str = "<select onChange='ShowCalendar(this.value,"+sMonth+",1); return false;' style='width:70; background-color:#D4E6FD; color:#0958AD; font-weight:bold;'>";
for(var i=min; i<=max; i++) {
if (i == intYear) {
str += "<option value="+i+" selected>"+i+"년</option>";
} else {
str += "<option value="+i+">"+i+"년</option>";
}
}
str += "</select>";
return str;
}

//월 정보를 콤보 박스로 표시
function getMonthinfo(sYear, sMonth)
{
var intMonth = new Number();
intMonth = parseInt(sMonth);

var str = "<select onChange='ShowCalendar("+sYear+",this.value,1); return false;' style='width:55; background-color:#D4E6FD; color:#0958AD; font-weight:bold;'>";
for(var i=1; i<=12; i++) {
if (i == intMonth) {
str += "<option value="+i+" selected>"+i+"월</option>";
} else {
str += "<option value="+i+">"+i+"월</option>";
}
}
str += "</select>";
return str;
}

//달력 표현
function ShowCalendar(sThisYear, sThisMonth, sThisDay)
{
var Months_day = new Array(0,31,28,31,30,31,30,31,31,30,31,30,31)
var Weekday_name = new Array("일", "월", "화", "수", "목", "금", "토");

var intThisYear = new Number(), intThisMonth = new Number(), intThisDay = new Number();
intThisYear = parseInt(sThisYear);
intThisMonth = parseInt(sThisMonth);
intThisDay = parseInt(sThisDay);
//값이 없을 경우
if(intThisYear == 0) intThisYear = datToday.getFullYear();
if(intThisMonth == 0) intThisMonth = datToday.getMonth()+1; // 월 값은 실제값 보다 -1 한 값임.
if(intThisDay == 0) intThisDay = datToday.getDate();
//윤년 처리
if((intThisYear % 4)==0) {
if((intThisYear % 100) == 0) {
if((intThisYear % 400) == 0) {
Months_day[2] = 29;
}
} else {
Months_day[2] = 29;
}
}

//이전.후 년월 설정 (화살표 이동)
switch(intThisMonth) {
case 1:
intPrevYear = intThisYear -1;
intPrevMonth = 12;
intNextYear = intThisYear;
intNextMonth = 2;
break;
case 12:
intPrevYear = intThisYear;
intPrevMonth = 11;
intNextYear = intThisYear + 1;
intNextMonth = 1;
break;
default:
intPrevYear = intThisYear;
intPrevMonth = intThisMonth - 1;
intNextYear = intThisYear;
intNextMonth = intThisMonth + 1;
break;
}

//호출날짜 객체 생성
datThisDay = new Date(intThisYear, intThisMonth, intThisDay);
//호출날짜의 요일
intThisWeekday = datThisDay.getDay();
//호출날짜의 요일명
varThisWeekday = Weekday_name[intThisWeekday];
//호출날짜의 마지막일자
intLastDay = Months_day[intThisMonth];

//호출날짜의 월의 1일로 날짜 객체 생성(월은 0부터 11까지의 정수(1월부터 12월))
datFirstDay = new Date(intThisYear, intThisMonth-1, 1);
//호출날짜의 달 1일의 요일을 구함 (0:일요일, 1:월요일)
intFirstWeekday = datFirstDay.getDay();
//노출 처리용
intThirdWeekday = intFirstWeekday; //요일
thirdPrintDay = 1; //일

Stop_flag = 0;
Cal_HTML = "<table border='0' cellspacing='0' cellpadding='0' style='margin-top:2'>";
Cal_HTML += "<tr>";
Cal_HTML += "<td><img onClick='ShowCalendar("+intPrevYear+","+intPrevMonth+",1);' alt='"+intPrevYear+"-"+intPrevMonth+"' src='http://newsimg.kbs.co.kr/images/200602/common/b_back.gif' align=absmiddle></td>";
Cal_HTML += "<td style='color:#8D6A0A; padding-left:8'>"+getYearinfo(intThisYear,intThisMonth)+"</td>";
Cal_HTML += "<td style='color:#8D6A0A; padding-left:8'>"+getMonthinfo(intThisYear,intThisMonth)+"</td>";
Cal_HTML += "<td style='padding-left:8'><img onClick='ShowCalendar("+intNextYear+","+intNextMonth+",1);' alt='"+intNextYear+"-"+intNextMonth+"' src='http://newsimg.kbs.co.kr/images/200602/common/b_front.gif' align=absmiddle></td>";
Cal_HTML += "</tr>";
Cal_HTML += "</table>\n";

Cal_HTML += "<table border='0' cellspacing='0' cellpadding='0' style='margin-top:2;'>";
Cal_HTML += "<tr height=24 align=center>";
Cal_HTML += "<td width=27 style='color:red;'>일</td>";
Cal_HTML += "<td width=27 style='color:green;'>월</td>";
Cal_HTML += "<td width=27 style='color:green;'>화</td>";
Cal_HTML += "<td width=27 style='color:green;'>수</td>";
Cal_HTML += "<td width=27 style='color:green;'>목</td>";
Cal_HTML += "<td width=27 style='color:green;'>금</td>";
Cal_HTML += "<td width=27 style='color:blue;'>토</td>";
Cal_HTML += "</tr>\n";

for(intLoopWeek=1; intLoopWeek<7; intLoopWeek++)  { // 주단위 루프 시작, 최대 6주
if(Stop_flag==1) { break; }
Cal_HTML += "<tr height=20 align=center>"
for(intLoopDay=1; intLoopDay<=7; intLoopDay++)  { // 요일단위 루프 시작, 일요일 부터
//월의 first day의 요일 위치
if(intThirdWeekday > 0)  {
Cal_HTML += "<td width=27></td>";
intThirdWeekday--;
continue;

//월의 last day의 요일 위치
if(thirdPrintDay > intLastDay)  {
Cal_HTML += "<td width=27></td>";
continue;

Cal_HTML += "<td width=27 title='"+intThisYear+"-"+day2(intThisMonth).toString()+"-"+day2(thirdPrintDay).toString()+"'";

Cal_HTML += "><a href='javascript:doClick("+intThisYear+","+intThisMonth+","+thirdPrintDay+");'"
switch(intLoopDay) {
case 1: // 일요일
Cal_HTML += " style='color:red;'"
break;
case 7: // 토요일
Cal_HTML += " style='color:blue;'"
break;
default: // 평일
Cal_HTML += " style='color:black;'"
break;
}
//오늘인가?
if(intThisYear == NowThisYear && intThisMonth==NowThisMonth && thirdPrintDay==NowThisDay)  {
Cal_HTML += "><b>"+thirdPrintDay+"</b></a>";
} else {
Cal_HTML += ">"+thirdPrintDay+"</a>";
}

thirdPrintDay++;
Cal_HTML += "</td>";

// 만약 날짜 값이 월말 값보다 크면 루프문 탈출
if(thirdPrintDay > intLastDay)  {
Stop_flag = 1;
}
}

Cal_HTML += "</tr>\n";
}

Cal_HTML += "</table>\n";

document.all.minical.innerHTML = "";
document.all.minical.innerHTML = Cal_HTML;

//for debug
//document.all.source.value = Cal_HTML;
}
</script>

</body>
<body>
<table width="215" border="0" cellspacing="0" cellpadding="0" style="border:1px solid #9FC8FD">
<tr><td style="padding:0 5 4 3; border:1px solid #E0ECFC; background-color:#D4E6FD"><center>달 력</center>
<table width="100%" border="0" cellpadding="0" cellspacing="0" style="border:1px solid #659BE0">
<tr><td align="center" valign="top" style="padding:7 12 7 12; background-color:#FFFFFF">
<div id="minical"></div>
</td></tr>
</table>
</td></tr>
</table>

<script language="JavaScript" type="text/JavaScript">ShowCalendar(2009,5,15);</script>

<!--/달력 -->
<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td height="10"></td></tr></table>
</body>
</html>
2009. 5. 19. 10:22

How to get value from TextBox, RadioButtonList, DropDownList, CheckBox through JavaScript

출처 : http://www.dotnetfunda.com/articles/article72.aspx

내가 만든 샘플 코드 링크 : 

신규 Web Form 에 스크립트와 html만 복사하면 됨.

In day to day life generally we need to get values from asp.net server controls through JavaScript while developing web applications. I found several questions on the internet for the same subject. In this article I am going to show how to get values from asp.net controls like TextBox, RadioButtonList, DropDownList, CheckBoxes. 


This picture is the UI screenshots of the the code I am going to present in this article



Getting TextBox Value in JavaScript

.aspx page code
Following code will render a TextBox and a Button control as displayed in the picture above.

<table> <tr> <th colspan="2" align="left"> Getting TextBox Value in JavaScript: </th> </tr> <tr> <td> <asp:TextBox ID="txt1" runat="server"></asp:TextBox> </td> <td> <input type="button" value="Submit" onclick="GetTextBoxValue('<%= txt1.ClientID %>')" /> </td> </tr> </table>


JavaScript function
Following code is JavaScript function to get value from TextBox control.
// Get TextBox value
function GetTextBoxValue(id)
{
    alert(document.getElementById(id).value);
}


Getting DropDownList/ListBox selected value

Following code will render a DropDown (Html select control) and a button as displayed in the picture above.
.aspx code
<table>
<tr>
    <th colspan="2" align="left">
        Getting DropDown/ListView Value
    </th>
</tr>
<tr>
    <td>
        <asp:DropDownList ID="dropDown" runat="Server">
            <asp:ListItem Text="Item 1" Value="1" Selected="True"></asp:ListItem>
            <asp:ListItem Text="Item 2" Value="2"></asp:ListItem>
            <asp:ListItem Text="Item 3" Value="3"></asp:ListItem>
        </asp:DropDownList>
    </td>
    <td>
        <input type="button" value="Submit" onclick="GetDropDownValue('<%= dropDown.ClientID %>')" />
    </td>
</tr>
</table>

JavaScript Code
Following is the JavaScript function to get the value from DropDown control
// Get DropDown value
function GetDropDownValue(id)
{
    alert(document.getElementById(id).value);
}


Getting RadioButtonList selected value

Following code will render RadioButtons and a button as displayed in the picture above.
.aspx code
<table>
    <tr>
        <th colspan="2" align="left">
            Getting RadioButton Value
        </th>
    </tr>
    <tr>
        <td>
            <asp:RadioButtonList ID="radiobuttonlist1" runat="Server" RepeatLayout="flow" RepeatDirection="horizontal">
                <asp:ListItem Text="Radio 1" Value="1" Selected="True"></asp:ListItem>
                <asp:ListItem Text="Radio 2" Value="2"></asp:ListItem>
                <asp:ListItem Text="Radio 3" Value="3"></asp:ListItem>
            </asp:RadioButtonList>
        </td>
        <td>
            <input type="button" value="Submit" onclick="GetRadioButtonValue('<%= radiobuttonlist1.ClientID %>')" />
        </td>
    </tr>
</table>

JavaScript Code
Following is the JavaScript function to get the selected value from RadioButtons
// Get radio button list value
function GetRadioButtonValue(id)
{
    var radio = document.getElementsByName(id);
    for (var ii = 0; ii < radio.length; ii++)
    {
        if (radio[ii].checked)
            alert(radio[ii].value);
    }
}


Getting CheckBox checked status

Following code will render a checkbox and a button as displayed in the picture above.
.aspx code
<table>
    <tr>
        <th colspan="2" align="left">
            Getting Checkbox Value
        </th>
    </tr>
    <tr>
        <td>
            <asp:CheckBox runat="server" ID="checkBox1" Text="Check Box" />
        </td>
        <td>
            <input type="button" value="Submit" onclick="GetCheckBoxValue('<%= checkBox1.ClientID %>')" />
        </td>
    </tr>
</table>

JavaScript Code
Following is the JavaScript function to get value from a Checkbox.
// Get Checkbox checked status
function GetCheckBoxValue(id)
{
    alert(document.getElementById(id).checked);
}



Show/Hide Text using

Following code will render three buttons and a table element having some text as displayed in the picture above.
.aspx code

<b>Show/Hide display text</b><br />
<input type="button" value="Toggle Display Following Text" onclick="ToggleFollowingText('table1')" />
<input type="button" value="Show Only" onclick="ShowOrHide('show', 'table1')" /> 
<input type="button" value="Hide Only" onclick="ShowOrHide('hide', 'table1')" />
<table id="table1">
    <tr>
        <td style="background-color:Aqua">
            This is my hidden text, You can play with it by clicking above button.
        </td>
    </tr>
</table>


JavaScript Code
Following is the JavaScript function to toggle display the table and show and hide element the table.

// Show/Hide element function ToggleFollowingText(id) { document.getElementById(id).style.display == '' ? document.getElementById(id).style.display = 'none' : document.getElementById(id).style.display = ''; } // Either show or hide element function ShowOrHide(condition, id) { if (condition == 'show') document.getElementById(id).style.display = ''; else if (condition == 'hide') document.getElementById(id).style.display = 'none'; }
2009. 5. 18. 09:18

Running Stored Procedures with ASP.NET


출처 : http://www.dotnetjunkies.ddj.com/Article/9AE62C44-3841-4687-B906-2F6D4A5A4622.dcik
원 소스는 위 링크에서 퍼 왔는데, 지금은 사라졌음.

최초 VB로 된 소스였는데.. C#으로 포팅함.

1. DB 접속해서 SP 목록 가져오고,
2. SP 선택해서 파라미터 가져오고,
3. Input Value 넣고 실행하면,
4. 결과를 알려줌.

RunStoredProcedures2.aspx : VB 소스

RunStoredProcedures.aspx : C# 소스


2009. 4. 30. 19:31

DataTable DataSet DataView Method


DataSet 으로 가져온 데이터를 기반으로 추가로 데이터를 가공할 경우가 필요해서 정리함.

http://www.codeguru.com/forum/showthread.php?t=332574

    DataSet ds = RepeaterProductInfo.DataSource as DataSet;
    DataRow [] row = ds.Tables[0].Select("Sum(ItemPrice)");
    strReturnValue = row[0][0].ToString();
    DataSet ds = RepeaterProductInfo.DataSource as DataSet;
    DataRow [] row = ds.Tables[0].Select("ItemPrice = Sum(ItemPrice)");
    strReturnValue = row[0][0].ToString();

DataTable.Compute Method
private void ComputeBySalesSalesID(DataSet dataSet)
{
    // Presumes a DataTable named "Orders" that has a column named "Total."
    DataTable table;
    table = dataSet.Tables["Orders"];

    // Declare an object variable.
    object sumObject;
    sumObject = table.Compute("Sum(Total)", "EmpID = 5");
}


Repeater Control and Data Binding - ASP .Net and C#

Introduction:

 Data Binding is the process of creating a link between the data source and the presentation UI to display the data. ASP .Net provides rich and wide variety of controls which can be bound to the data. This model of binding data with the data source reduces a lot of code complexity and increases the ease of maintenance of code. This article looks at how to use this data binding feature for a Repeater control in ASP .Net with C# code.

Repeater Control in ASP .Net:

   A Repeater control is a light weight control which can be used for simple reporting purposes. It supports basic event-handling like Init, Load, Unload etc., This also supports some basic formatting of data and can be presented to the user. A Repeater control offers limited level of data editing or selecting capabilities. For such editing and updates ASP .Net offers DataList and DataGrid controls.

   A Repeater control can be used to build small and Flexible reports with the templates for the items. It supports the following five templates.

  • HeaderTemplate : Can be used to create the Header Rows of the Table data being presented by Repeater control.
  • FooterTemplate : Can be used to create the Footer Rows of the Table data being presented by Repeater control.
  • ItemTemplate : Used for formatting the Items and rows to be displayed.
  • AlternatingItemTemplate : Alternating items formatting.
  • SeparatorTemplate : Styles for separating rows and columns.

   There are many ways in which a control in ASP .Net can be formatted. It is up to the imagination of the programmer to come up with nice formats. For example the Footer rows can be manipulated in such a way that, it can show the summary values or totals etc.,

Repeater Syntax:

<asp:Repeater id="idrepeater" runat="server" Datasource="<%# dataset %>" DataMember="table-inside-dataset">
<HeaderTemplate>..Header Format ..</HeaderTemplate>
<ItemTemplate> .. Item formats .. </ItemTemplate> 
</asp:Repeater>

    As given above, the syntax is simply the Repeater tag with the Template types. These templates can be formatted with ItemStyle tags also.

Using DataBinder.Eval method:

   The System.Web.UI.DataBinder class provides a useful static method DataBinder.Eval, which can be used to evaluate the data at run time using late binding. This function can be used with the Visual Studio IDE or can be manually coded as

 

<%#  DataBinder.Eval(Container.DataItem,"FieldName","Format") %>

   This evaluates and returns the data at run time. This can be used with Repeater, DataList and DataGrid controls though there will be a performance penalty because of the late binding mechanism used.

Creating a Sample Program with Repeater Control:

   Let's create a small sample program with the Repeater control. 

  1. Add a new Webform in an Visual Studio  Asp .net application.
  2. Add a Repeater control to the application. Let us assume that the id of the control is Repeater1.
  3. Insert the following lines of formatting code in between the opening and closing tags of the <asp:Repeater> control.
  4. <HeaderTemplate>
    <table cellpadding="5" cellspacing="2" >
    <tr bgcolor=Gray>
    <td><b>CustomerName</b></td>
    <td><b>Country</b></td>
    </tr>
    </HeaderTemplate>
    <ItemTemplate>
    <tr>
    <td><%# DataBinder.Eval(Container.DataItem,"CustomerName") %></td>
    <td><%# DataBinder.Eval(Container.DataItem,"Country") %></td>
    </tr>
    </ItemTemplate>
    <AlternatingItemTemplate>
    <tr bgcolor="#ccccff">
    <td><%# DataBinder.Eval(Container.DataItem,"CustomerName") %></td>
    <td><%# DataBinder.Eval(Container.DataItem,"Country") %></td>
    </tr>
    </AlternatingItemTemplate>
    <FooterTemplate>
    </table>
    </FooterTemplate>
  5. The above code just adds the repeater control with formatting for the header rows, data rows and the footer rows. The HeaderTemplate starts the <table> tag with the table heading and the FooterTemplate closes it.
  6. Now, Add the following code inside the Webform1.aspx.cs, Page_Load event.
    DataSet ds = new DataSet();
    DataTable dt = ds.Tables.Add("Customer");
    dt.Columns.Add("CustomerName",Type.GetType("System.String"));
    dt.Columns.Add("Country",Type.GetType("System.String"));

    DataRow dr = dt.NewRow();
    dr[0]="Testcustomer1";
    dr[1]="USA";
    dt.Rows.Add(dr);

    dr = dt.NewRow();
    dr[0]="Testcustomer2";
    dr[1]="UK";
    dt.Rows.Add(dr);

    dr = dt.NewRow();
    dr[0]="Testcustomer3";
    dr[1]="GERMANY";
    dt.Rows.Add(dr);

    dr = dt.NewRow();
    dr[0]="Testcustomer4";
    dr[1]="FRANCE";
    dt.Rows.Add(dr);

    //Bind the data to the Repeater
    Repeater1.DataSource = ds;
    Repeater1.DataMember = "Customer";
    Repeater1.DataBind();
  7. The above code creates a dataset to be used with the Repeater control. The repeater's datasource is the Dataset created and the Data member is mentioned as the Table which is created along with the dataset. This enables the Repeater to create the list of items from this customer table.
  8. Now build the application in Visual Studio .Net and load this page. The data will be shown in a tabular format.

   The above sample shows data binding from a statically created data set only. This can be very easily extended to a DataSet generated from database tables, xml files or even DataView s.

   Ultimately, this Repeater control can be used for light weight and simple report generation. This has only a very simple level event handling capabilities. Also there is a performance penalty because of using the DataBinder.Eval methods, this can be considered for data which are not modified frequently. If it is a large amount of data, then caching may be considered to improve the performance, though there are some other factors may have to be considered and not discussed here.

Attachments:

  Project Files : RepeaterSample.zip


Repeater Class


리피터 컨트롤 (Repeater Contorl) 사용시 빈 데이터 핸들링

강력하고 우아한 리피터 컨트롤을 가지고 빈데이터가 왔을경우 어떻게 표시할 수 있는지 그 처리를 위한 기본 메커니즘을 알아봅시다. 예를 들어 다른 컨트롤인 그리드 뷰 같은 경우, 바인드 되는 데이터가 비어있을 경우를 대비해서 그에 관한 속성을 지원합니다. (EmptyDataTemplate)
그렇지만 리피터 컨트롤에는 그와 같은 속성을 지원하지 않습니다. 다만, 리피터 컨트롤의 고유한 유연성으로 이 기능을 추가 시키기 쉽게 되어있습니다. 그럼 데이터가 비었을때 그와 관련된 메시지를 어떻게 나타내주는지 알아보도록 하겠습니다.

아래 예제는 리피터 컨트롤을 사용하여 테이블을 만들어 내는 코드 입니다.

<asp:Repeater runat="server" ID="Repeater1">
    <HeaderTemplate>
        <table width="80%">
    </HeaderTemplate>
    
    <ItemTemplate>
        <tr>
            <td><asp:Label runat="server" Text='<%# Eval("Model") %>' /></td>
        </tr>
    </ItemTemplate>
    
    <FooterTemplate>
        </table>
    </FooterTemplate>
</asp:Repeater>
 
if (!IsPostBack)
{
    List<Car> cars = new List<Car>();

    Repeater1.DataSource = cars;
    Repeater1.DataBind();
}

만약 위 코드에서 바인딩한 cars 에 빈값이 들어있다면 위 ItemTemplate는 사용되지 않고 리피터 컨트롤은 빈값을 나타내게 됩니다.  아래 코드는 그 결과입니다. Header와 Footer Template만 랜더링 되어있습니다.

<table width="80%">
            
</table>

위에서 보았듣이 Header나 Footer의 경우 데이터의 유/무와 상관없이 랜더링이 됩니다. 이를 이용하여 데이터를 기반으로 하여 빈 데이터시에 그 내용을 나타내 줄 수 있습니다.

아래 코드를 살펴 보겠습니다.

<table width="80%">
    <tr runat="server" 
        visible='<%# ((ICollection)Repeater1.DataSource).Count == 0 ? true : false %>'>
        <td>
            There is no data to display
        </td>
    </tr>

There are a couple of items that should be noted in the above example.

  • The Repeater has been referenced by it's  ID.
  • The DataSource property of the Repeater has been cast to an ICollection object. DataSource is defined as type object, but when data is bound to it, it must be of type ICollection. We are using the Count property from this interface to determine if the "Empty Data" message should display.

When there are several controls where the Visible property needs to be set, the logic can be moved to the code-behind for the page. This is shown in the following IsDataEmpty property.

protected bool IsDataEmpty
{
    get
    {
        ICollection list = Repeater1.DataSource as ICollection;

        return list.Count == 0 ? true : false;
    }
}

The ASPX will change to reference this property as follows:

<table width="80%">
    <tr runat="server" 
        visible='<%# IsDataEmpty %>'>
        <td>
            There is no data to display
        </td>
    </tr>

Regardless of which approach you use, the resulting HTML will now look like:

<table width="80%">
    <tr>
        <td>
            There is no data to display
        </td>
    </tr>   
</table>

As shown in the above examples, it is fairly simple to add HTML that will conditionally render based on the presence (or lack) of data bound to a Repeater.

출처 : http://devcenter.auburnrandall.com/Default.aspx?c=Tech&type=post&id=72


C# DataTable Group by Example

http://programming.top54u.com/post/C-sharp-DataTable-Group-by-Example.aspx

DataTable tbl1 = dset.Tables[0];

DataTable tbl2 = dset.Tables[1];

GridView1.DataSource = tbl2;
GridView1.DataBind();


int counter = 0;

// for each loop to group the records by categoryid
foreach (DataRow dr in tbl2.Rows)
{
    DataView dv = tbl1.DefaultView;
    dv.RowFilter = "categoryid=" + dr["categoryid"];

    GridView grd = (GridView)GridView1.Rows[counter].Cells[0].FindControl("GridView2");

    grd.DataSource = tbl1;
    grd.DataBind();

    counter++;
}




2009. 4. 17. 17:30

javascript 에서 html 오브젝트 value 가져오기


javascript 에서 html 오브젝트 value 가져오기

1과 2는 동일하게 동작한다.

1. ---------------------------------------------
        var strWhNm = "<%=txtWhNm.ClientID%>";
        var strWhCd = "<%=hfWhCd.ClientID%>";
        var strProdClassNm = "<%=txtProdClassNm.ClientID %>";
        var strProdClassCd = "<%=hfProdClassCd.ClientID%>";
        var strProdNm = "<%=txtProdNm.ClientID %>";
        var strProdCd = "<%=hfProdCd.ClientID%>";

        var strWhNmValue = document.all[strWhNm].value;
        var strWhCdValue = document.all[strWhCd].value;
        var strProdClassNmValue = document.all[strProdClassNm].value;
        var strProdClassCdValue = document.all[strProdClassCd].value;
        var strProdNmValue = document.all[strProdNm].value;
        var strProdCdValue = document.all[strProdCd].value;

2. ---------------------------------------------
        var strWhNmValue = window.document.forms[0].<%=txtWhNm.ClientID%>.value;
        var strWhCdValue = window.document.forms[0].<%=hfWhCd.ClientID%>.value;
        var strProdClassNmValue = window.document.forms[0].<%=txtProdClassNm.ClientID%>.value;
        var strProdClassCdValue = window.document.forms[0].<%=hfProdClassCd.ClientID%>.value;
        var strProdNmValue = window.document.forms[0].<%=txtProdNm.ClientID%>.value;
        var strProdCdValue = window.document.forms[0].<%=hfProdCd.ClientID%>.value;

2009. 4. 13. 15:49

각종 인터넷 에러메시지


출처 : http://k.daum.net/qna/openknowledge/view.html?qid=2bzvR&q=%BF%A1%B7%AF&nil_no=29440

인터넷 에러메시지를 많이 보셨죠? 그 중에서 가장 대표적인 에러 메시지들을 소개합니다.

빠른 찾기는 ctrl+F 를 누르시면 됩니다.


▶ 403 Forbidden/Access Denied (403 금지/액세스 거부)

이 웹 사이트는 패스워드와 같은 특별한 액세스 승인을 필요로 하는
경우입니다.


▶ 404 Not Found (404 찾을 수 없음)

브라우저가 호스트 컴퓨터는 찾았으나 요청된 특정 도큐먼트를 찾지 못한 경우입니다.
정확한 주소를 입력했는지 확인해 봅니다. 그 페이지는 해당 웹 사이트에서 제거되었을 수도 있고 위치가 바뀌었을 수도 있습니다. 파일명을 떼어내고 주소를 다시 한 번 입력해 봅니다. 즉, 한 단계 위의 웹 사이트를 찾아 봅니다.

 

▶ 503 Service Unavailable (503 서비스 불가)

해당 웹 사이트의 서버에 과부하가 걸린 경우입니다.
몇 초 후에 다시 시도해 봅니다.

 

▶ Bad file request (잘못된 파일 요청)

온라인 폼 또는 HTML 코드가 잘못된 경우입니다.

 

▶ Connection refused by host (호스트의 접속 거부)

위에 있는 ‘403 Forbidden/Access Denied’ 에러와 유사한 상황입니다.

 

▶ Failed DNS lookup (DNS 찾기 실패)

해당 웹 사이트의 URL이 적절한 IP 주소로 전환될 수 없는 경우입니다.
이런 에러는 상용 사이트에서 빈번하게 발생하는데 IP 주소 전환을 담당하는 컴퓨터들이 과부하 상태에 놓이기 때문이라고 합니다.
물론, 주소를 잘못 입력한 경우에도 발생할 수 있습니다.
주소를 다시 한 번 입력해 보거나, 혼잡하지 않을 것 같은 시간에 다시 시도해 봅니다.

 

▶ Helper application not found

보조 응용프로그램(helper application)을 필요로 하는 파일을 다운받으려 하는데, 인터넷 익스플로러가 찾지 못하는 경우입니다.
이런 경우에는 아무 Windows 창이나 열어서 ‘보기(V)’의 ‘폴더 옵션(O)’에 있는 ‘파일 형식’ 탭을 선택하여 보조 응용프로그램을 위한 디렉토리 및 파일명이 정확하게 입력되도록 합니다.

 

▶ Not found (찾을 수 없음)

하이퍼링크가 가리키는 웹 페이지가 더 이상 존재하지 않음을 나타냅니다.

 

▶ Site unavailable (사이트 사용 불가)

너무 많은 사람들이 동시에 액세스하려 하면 온라인상에 노이즈가 생겨 해당 사이트가 다운될 수도 있고, 아니면 더 이상 그 사이트가 존재하지 않는 경우일 수도 있습니다. 주소를 잘못 입력해도 나올 수 있습니다.


▶ 각 Error 코드별 의미

100 : Continue
101 : Switching protocols
200 : OK, 에러없이 전송 성공
201 : Created, POST 명령 실행 및 성공
202 : Accepted, 서버가 클라이언트 명령을 받음
203 : Non-authoritative information, 서버가 클라이언트 요구 중 일부 만 전송
204 : No content, 클라언트 요구을 처리했으나 전송할 데이터가 없음
205 : Reset content
206 : Partial content
300 : Multiple choices, 최근에 옮겨진 데이터를 요청
301 : Moved permanently, 요구한 데이터를 변경된 임시 URL에서 찾았음
302 : Moved temporarily, 요구한 데이터가 변경된 URL에 있음을 명시
303 : See other, 요구한 데이터를 변경하지 않았기 때문에 문제가 있음
304 : Not modified
305 : Use proxy
400 : Bad request, 클라이언트의 잘못된 요청으로 처리할 수 없음
401 : Unauthorized, 클라이언트의 인증 실패
402 : Payment required, 예약됨
403 : Forbidden, 접근이 거부된 문서를 요청함
404 : Not found, 문서를 찾을 수 없음
405 : Method not allowed, 리소스를 허용안함
406 : Not acceptable, 허용할 수 없음
407 : Proxy authentication required, 프록시 인증 필요
408 : Request timeout, 요청시간이 지남
409 : Conflict
410 : Gone, 영구적으로 사용할 수 없음
411 : Length required
412 : Precondition failed, 전체조건 실패
413 : Request entity too large,
414 : Request-URI too long, URL이 너무 김
415 : Unsupported media type
500 : Internal server error, 내부서버 오류(잘못된 스크립트 실행시)
501 : Not implemented, 클라이언트에서 서버가 수행할 수 없는 행동을 요구함
502 : Bad gateway, 서버의 과부하 상태
503 : Service unavailable, 외부 서비스가 죽었거나 현재 멈춤 상태
504 : Gateway timeout
505 : HTTP version not supported

2009. 4. 11. 11:54

Training Kit