<% Session.Timeout = 900 %>
<%

' Define page object
Dim xwlm_grid
Set xwlm_grid = New cxwlm_grid
Set Grid = xwlm_grid

' Page init processing
xwlm_grid.Page_Init()

' Page main processing
xwlm_grid.Page_Main()

' Global Page Rendering event (in userfn*.asp)
Page_Rendering()

' Page Rendering event
xwlm_grid.Page_Render()
%>
<% If xwlm.Export = "" Then %>
<script type="text/javascript">
// Page object
var xwlm_grid = new ew_Page("xwlm_grid");
xwlm_grid.PageID = "grid"; // Page ID
var EW_PAGE_ID = xwlm_grid.PageID; // For backward compatibility
// Form object
var fxwlmgrid = new ew_Form("fxwlmgrid");
fxwlmgrid.FormKeyCountName = '<%= xwlm_grid.FormKeyCountName %>';
// Validate form
fxwlmgrid.Validate = function() {
	if (!this.ValidateRequired)
		return true; // Ignore validation
	var $ = jQuery, fobj = this.GetForm(), $fobj = $(fobj);
	this.PostAutoSuggest();
	if ($fobj.find("#a_confirm").val() == "F")
		return true;
	var elm, felm, uelm, addcnt = 0;
	var $k = $fobj.find("#" + this.FormKeyCountName); // Get key_count
	var rowcnt = ($k[0]) ? parseInt($k.val(), 10) : 1;
	var startcnt = (rowcnt == 0) ? 0 : 1; // Check rowcnt == 0 => Inline-Add
	var gridinsert = $fobj.find("#a_list").val() == "gridinsert";
	for (var i = startcnt; i <= rowcnt; i++) {
		var infix = ($k[0]) ? String(i) : "";
		$fobj.data("rowindex", infix);
		var checkrow = (gridinsert) ? !this.EmptyRow(infix) : true;
		if (checkrow) {
			addcnt++;
			elm = this.GetElements("x" + infix + "_px");
			if (elm && !ew_CheckInteger(elm.value))
				return this.OnError(elm, "<%= ew_JsEncode2(xwlm.px.FldErrMsg) %>");
			// Set up row object
			ew_ElementsToRow(fobj);
			// Fire Form_CustomValidate event
			if (!this.Form_CustomValidate(fobj))
				return false;
		} // End Grid Add checking
	}
	return true;
}
// Check empty row
fxwlmgrid.EmptyRow = function(infix) {
	var fobj = this.Form;
	if (ew_ValueChanged(fobj, infix, "bh", false)) return false;
	if (ew_ValueChanged(fobj, infix, "lmmc", false)) return false;
	if (ew_ValueChanged(fobj, infix, "lmmc2", false)) return false;
	if (ew_ValueChanged(fobj, infix, "px", false)) return false;
	if (ew_ValueChanged(fobj, infix, "urllb", false)) return false;
	return true;
}
// Form_CustomValidate event
fxwlmgrid.Form_CustomValidate = 
 function(fobj) { // DO NOT CHANGE THIS LINE!
 	// Your custom validation code here, return false if invalid. 
 	return true;
 }
// Use JavaScript validation or not
<% If EW_CLIENT_VALIDATE Then %>
fxwlmgrid.ValidateRequired = true; // Use JavaScript validation
<% Else %>
fxwlmgrid.ValidateRequired = false; // No JavaScript validation
<% End If %>
// Dynamic selection lists
fxwlmgrid.Lists["x_bh"] = {"LinkField":"x_bh","Ajax":null,"AutoFill":false,"DisplayFields":["x_bhmc","","",""],"ParentFields":[],"FilterFields":[],"Options":[]};
// Form object for search
</script>
<% End If %>
<%
If xwlm.CurrentAction = "gridadd" Then
	If xwlm.CurrentMode <> "copy" Then xwlm.CurrentFilter = "0=1"
End If

' Load recordset
Set xwlm_grid.Recordset = xwlm_grid.LoadRecordset()
If xwlm.CurrentAction = "gridadd" Then
	If xwlm.CurrentMode = "copy" Then
		xwlm_grid.TotalRecs = xwlm_grid.Recordset.RecordCount
		xwlm_grid.StartRec = 1
		xwlm_grid.DisplayRecs = xwlm_grid.TotalRecs
	Else
		xwlm_grid.StartRec = 1
		xwlm_grid.DisplayRecs = xwlm.GridAddRowCount
	End If
	xwlm_grid.TotalRecs = xwlm_grid.DisplayRecs
	xwlm_grid.StopRec = xwlm_grid.DisplayRecs
Else
	xwlm_grid.TotalRecs = xwlm_grid.Recordset.RecordCount
	xwlm_grid.StartRec = 1
	xwlm_grid.DisplayRecs = xwlm_grid.TotalRecs ' Display all records
End If
xwlm_grid.RenderOtherOptions()
%>
<% xwlm_grid.ShowPageHeader() %>
<% xwlm_grid.ShowMessage %>
<table class="ewGrid"><tr><td class="ewGridContent">
<div id="fxwlmgrid" class="ewForm form-inline">
<% If xwlm_grid.ShowOtherOptions Then %>
<div class="ewGridUpperPanel ewListOtherOptions">
<%
	xwlm_grid.AddEditOptions.Render "body", "", "", "", "", ""
%>
</div>
<% End If %>
<div id="gmp_xwlm" class="ewGridMiddlePanel">
<table id="tbl_xwlmgrid" class="ewTable ewTableSeparate">
<%= xwlm.TableCustomInnerHtml %>
<thead><!-- Table header -->
	<tr class="ewTableHeader">
<%
Call xwlm_grid.RenderListOptions()

' Render list options (header, left)
xwlm_grid.ListOptions.Render "header", "left", "", "", "", ""
%>
<% If xwlm.lmid.Visible Then ' lmid %>
	<% If xwlm.SortUrl(xwlm.lmid) = "" Then %>
		<td><div id="elh_xwlm_lmid" class="xwlm_lmid"><div class="ewTableHeaderCaption"><%= xwlm.lmid.FldCaption %></div></div></td>
	<% Else %>
		<td><div><div id="elh_xwlm_lmid" class="xwlm_lmid">
			<div class="ewTableHeaderBtn"><span class="ewTableHeaderCaption"><%= xwlm.lmid.FldCaption %></span><span class="ewTableHeaderSort"><% If xwlm.lmid.Sort = "ASC" Then %><span class="caret ewSortUp"></span><% ElseIf xwlm.lmid.Sort = "DESC" Then %><span class="caret"></span><% End If %></span></div>
        </div></div></td>
	<% End If %>
<% End If %>		
<% If xwlm.bh.Visible Then ' bh %>
	<% If xwlm.SortUrl(xwlm.bh) = "" Then %>
		<td><div id="elh_xwlm_bh" class="xwlm_bh"><div class="ewTableHeaderCaption"><%= xwlm.bh.FldCaption %></div></div></td>
	<% Else %>
		<td><div><div id="elh_xwlm_bh" class="xwlm_bh">
			<div class="ewTableHeaderBtn"><span class="ewTableHeaderCaption"><%= xwlm.bh.FldCaption %></span><span class="ewTableHeaderSort"><% If xwlm.bh.Sort = "ASC" Then %><span class="caret ewSortUp"></span><% ElseIf xwlm.bh.Sort = "DESC" Then %><span class="caret"></span><% End If %></span></div>
        </div></div></td>
	<% End If %>
<% End If %>		
<% If xwlm.lmmc.Visible Then ' lmmc %>
	<% If xwlm.SortUrl(xwlm.lmmc) = "" Then %>
		<td><div id="elh_xwlm_lmmc" class="xwlm_lmmc"><div class="ewTableHeaderCaption"><%= xwlm.lmmc.FldCaption %></div></div></td>
	<% Else %>
		<td><div><div id="elh_xwlm_lmmc" class="xwlm_lmmc">
			<div class="ewTableHeaderBtn"><span class="ewTableHeaderCaption"><%= xwlm.lmmc.FldCaption %></span><span class="ewTableHeaderSort"><% If xwlm.lmmc.Sort = "ASC" Then %><span class="caret ewSortUp"></span><% ElseIf xwlm.lmmc.Sort = "DESC" Then %><span class="caret"></span><% End If %></span></div>
        </div></div></td>
	<% End If %>
<% End If %>		
<% If xwlm.lmmc2.Visible Then ' lmmc2 %>
	<% If xwlm.SortUrl(xwlm.lmmc2) = "" Then %>
		<td><div id="elh_xwlm_lmmc2" class="xwlm_lmmc2"><div class="ewTableHeaderCaption"><%= xwlm.lmmc2.FldCaption %></div></div></td>
	<% Else %>
		<td><div><div id="elh_xwlm_lmmc2" class="xwlm_lmmc2">
			<div class="ewTableHeaderBtn"><span class="ewTableHeaderCaption"><%= xwlm.lmmc2.FldCaption %></span><span class="ewTableHeaderSort"><% If xwlm.lmmc2.Sort = "ASC" Then %><span class="caret ewSortUp"></span><% ElseIf xwlm.lmmc2.Sort = "DESC" Then %><span class="caret"></span><% End If %></span></div>
        </div></div></td>
	<% End If %>
<% End If %>		
<% If xwlm.px.Visible Then ' px %>
	<% If xwlm.SortUrl(xwlm.px) = "" Then %>
		<td><div id="elh_xwlm_px" class="xwlm_px"><div class="ewTableHeaderCaption"><%= xwlm.px.FldCaption %></div></div></td>
	<% Else %>
		<td><div><div id="elh_xwlm_px" class="xwlm_px">
			<div class="ewTableHeaderBtn"><span class="ewTableHeaderCaption"><%= xwlm.px.FldCaption %></span><span class="ewTableHeaderSort"><% If xwlm.px.Sort = "ASC" Then %><span class="caret ewSortUp"></span><% ElseIf xwlm.px.Sort = "DESC" Then %><span class="caret"></span><% End If %></span></div>
        </div></div></td>
	<% End If %>
<% End If %>		
<% If xwlm.urllb.Visible Then ' urllb %>
	<% If xwlm.SortUrl(xwlm.urllb) = "" Then %>
		<td><div id="elh_xwlm_urllb" class="xwlm_urllb"><div class="ewTableHeaderCaption"><%= xwlm.urllb.FldCaption %></div></div></td>
	<% Else %>
		<td><div><div id="elh_xwlm_urllb" class="xwlm_urllb">
			<div class="ewTableHeaderBtn"><span class="ewTableHeaderCaption"><%= xwlm.urllb.FldCaption %></span><span class="ewTableHeaderSort"><% If xwlm.urllb.Sort = "ASC" Then %><span class="caret ewSortUp"></span><% ElseIf xwlm.urllb.Sort = "DESC" Then %><span class="caret"></span><% End If %></span></div>
        </div></div></td>
	<% End If %>
<% End If %>		
<%

' Render list options (header, right)
xwlm_grid.ListOptions.Render "header", "right", "", "", "", ""
%>
	</tr>
</thead>
<tbody><!-- Table body -->
<%
xwlm_grid.StartRec = 1
xwlm_grid.StopRec = xwlm_grid.TotalRecs ' Show all records

' Restore number of post back records
If IsObject(ObjForm) And Not (ObjForm Is Nothing) Then
	ObjForm.Index = -1
	If ObjForm.HasValue(xwlm_grid.FormKeyCountName) And (xwlm.CurrentAction = "gridadd" Or xwlm.CurrentAction = "gridedit" Or xwlm.CurrentAction = "F") Then
		xwlm_grid.KeyCount = ObjForm.GetValue(xwlm_grid.FormKeyCountName)
		xwlm_grid.StopRec = xwlm_grid.StartRec + xwlm_grid.KeyCount - 1
	End If
End If

' Move to first record
xwlm_grid.RecCnt = xwlm_grid.StartRec - 1
If Not xwlm_grid.Recordset.Eof Then
	xwlm_grid.Recordset.MoveFirst
	If xwlm_grid.StartRec > 1 Then xwlm_grid.Recordset.Move xwlm_grid.StartRec - 1
ElseIf Not xwlm.AllowAddDeleteRow And xwlm_grid.StopRec = 0 Then
	xwlm_grid.StopRec = xwlm.GridAddRowCount
End If

' Initialize Aggregate
xwlm.RowType = EW_ROWTYPE_AGGREGATEINIT
Call xwlm.ResetAttrs()
Call xwlm_grid.RenderRow()
xwlm_grid.RowCnt = 0
If xwlm.CurrentAction = "gridadd" Then xwlm_grid.RowIndex = 0
If xwlm.CurrentAction = "gridedit" Then xwlm_grid.RowIndex = 0

' Output date rows
Do While CLng(xwlm_grid.RecCnt) < CLng(xwlm_grid.StopRec)
	xwlm_grid.RecCnt = xwlm_grid.RecCnt + 1
	If CLng(xwlm_grid.RecCnt) >= CLng(xwlm_grid.StartRec) Then
		xwlm_grid.RowCnt = xwlm_grid.RowCnt + 1
		If xwlm.CurrentAction = "gridadd" Or xwlm.CurrentAction = "gridedit" Or xwlm.CurrentAction = "F" Then
			xwlm_grid.RowIndex = xwlm_grid.RowIndex + 1
			ObjForm.Index = xwlm_grid.RowIndex
			If ObjForm.HasValue(xwlm_grid.FormActionName) Then
				xwlm_grid.RowAction = ObjForm.GetValue(xwlm_grid.FormActionName) & ""
			ElseIf xwlm.CurrentAction = "gridadd" Then
				xwlm_grid.RowAction = "insert"
			Else
				xwlm_grid.RowAction = ""
			End If
		End If

	' Set up key count
	xwlm_grid.KeyCount = xwlm_grid.RowIndex
	Call xwlm.ResetAttrs()
	xwlm.CssClass = ""
	If xwlm.CurrentAction = "gridadd" Then
		If xwlm.CurrentMode = "copy" Then
			Call xwlm_grid.LoadRowValues(xwlm_grid.Recordset) ' Load row values
			xwlm_grid.RowOldKey = xwlm_grid.SetRecordKey(xwlm_grid.Recordset) ' Set old record key
		Else
			Call xwlm_grid.LoadDefaultValues() ' Load default values
			xwlm_grid.RowOldKey = "" ' Clear old key value
		End If
	Else
		Call xwlm_grid.LoadRowValues(xwlm_grid.Recordset) ' Load row values
	End If
	xwlm.RowType = EW_ROWTYPE_VIEW ' Render view
	If xwlm.CurrentAction = "gridadd" Then ' Grid add
		xwlm.RowType = EW_ROWTYPE_ADD ' Render add
	End If
	If xwlm.CurrentAction = "gridadd" And xwlm.EventCancelled Then ' Insert failed
		If Not ObjForm.HasValue("k_blankrow") Then
			Call xwlm_grid.RestoreCurrentRowFormValues(xwlm_grid.RowIndex) ' Restore form values
		End If
	End If
	If xwlm.CurrentAction = "gridedit" Then ' Grid edit
		If xwlm.EventCancelled Then ' Update failed
			Call xwlm_grid.RestoreCurrentRowFormValues(xwlm_grid.RowIndex) ' Restore form values
		End If
		If xwlm_grid.RowAction = "insert" Then
			xwlm.RowType = EW_ROWTYPE_ADD ' Render add
		Else
			xwlm.RowType = EW_ROWTYPE_EDIT ' Render edit
		End If
	End If
	If xwlm.RowType = EW_ROWTYPE_EDIT Then ' Edit row
		xwlm_grid.EditRowCnt = xwlm_grid.EditRowCnt + 1
	End If
	If xwlm.CurrentAction = "F" Then ' Confirm row
		Call xwlm_grid.RestoreCurrentRowFormValues(xwlm_grid.RowIndex) ' Restore form values
	End If

	' Set up row id / data-rowindex
	xwlm.RowAttrs.AddAttributes Array(Array("data-rowindex", xwlm_grid.RowCnt), Array("id", "r" & xwlm_grid.RowCnt & "_xwlm"), Array("data-rowtype", xwlm.RowType))

	' Render row
	Call xwlm_grid.RenderRow()

	' Render list options
	Call xwlm_grid.RenderListOptions()

	' Skip delete row / empty row for confirm page
	If xwlm_grid.RowAction <> "delete" And xwlm_grid.RowAction <> "insertdelete" And Not (xwlm_grid.RowAction = "insert" And xwlm.CurrentAction = "F" And xwlm_grid.EmptyRow()) Then
%>
	<tr<%= xwlm.RowAttributes %>>
<%

' Render list options (body, left)
xwlm_grid.ListOptions.Render "body", "left", xwlm_grid.RowCnt, "", "", ""
%>
	<% If xwlm.lmid.Visible Then ' lmid %>
		<td<%= xwlm.lmid.CellAttributes %>>
<% If xwlm.RowType = EW_ROWTYPE_ADD Then ' Add Record %>
<input type="hidden" data-field="x_lmid" name="o<%= xwlm_grid.RowIndex %>_lmid" id="o<%= xwlm_grid.RowIndex %>_lmid" value="<%= Server.HTMLEncode(xwlm.lmid.OldValue&"") %>">
<% End If %>
<% If xwlm.RowType = EW_ROWTYPE_EDIT Then ' Edit Record %>
<span id="el<%= xwlm_grid.RowCnt %>_xwlm_lmid" class="control-group xwlm_lmid">
<span<%= xwlm.lmid.ViewAttributes %>>
<%= xwlm.lmid.EditValue %>
</span>
</span>
<input type="hidden" data-field="x_lmid" name="x<%= xwlm_grid.RowIndex %>_lmid" id="x<%= xwlm_grid.RowIndex %>_lmid" value="<%= Server.HTMLEncode(xwlm.lmid.CurrentValue&"") %>">
<% End If %>
<% If xwlm.RowType = EW_ROWTYPE_VIEW Then ' View Record %>
<span<%= xwlm.lmid.ViewAttributes %>>
<%= xwlm.lmid.ListViewValue %>
</span>
<input type="hidden" data-field="x_lmid" name="x<%= xwlm_grid.RowIndex %>_lmid" id="x<%= xwlm_grid.RowIndex %>_lmid" value="<%= Server.HTMLEncode(xwlm.lmid.FormValue&"") %>">
<input type="hidden" data-field="x_lmid" name="o<%= xwlm_grid.RowIndex %>_lmid" id="o<%= xwlm_grid.RowIndex %>_lmid" value="<%= Server.HTMLEncode(xwlm.lmid.OldValue&"") %>">
<% End If %>
<a id="<%= xwlm_grid.PageObjName & "_row_" & xwlm_grid.RowCnt %>"></a></td>
	<% End If %>
	<% If xwlm.bh.Visible Then ' bh %>
		<td<%= xwlm.bh.CellAttributes %>>
<% If xwlm.RowType = EW_ROWTYPE_ADD Then ' Add Record %>
<% If xwlm.bh.SessionValue <> "" Then %>
<span<%= xwlm.bh.ViewAttributes %>>
<%= xwlm.bh.ListViewValue %>
</span>
<input type="hidden" id="x<%= xwlm_grid.RowIndex %>_bh" name="x<%= xwlm_grid.RowIndex %>_bh" value="<%= ew_HtmlEncode(xwlm.bh.CurrentValue) %>">
<% Else %>
<select data-field="x_bh" id="x<%= xwlm_grid.RowIndex %>_bh" name="x<%= xwlm_grid.RowIndex %>_bh"<%= xwlm.bh.EditAttributes %>>
<%
emptywrk = True
If IsArray(xwlm.bh.EditValue) Then
	arwrk = xwlm.bh.EditValue
	For rowcntwrk = 0 To UBound(arwrk, 2)
		If arwrk(0, rowcntwrk)&"" = xwlm.bh.CurrentValue&"" Then
			selwrk = " selected=""selected"""
			emptywrk = False
		Else
			selwrk = ""
		End If
%>
<option value="<%= Server.HtmlEncode(arwrk(0, rowcntwrk)&"") %>"<%= selwrk %>>
<%= arwrk(1, rowcntwrk) %>
</option>
<%
	Next
End If
If emptywrk Then xwlm.bh.OldValue = ""
%>
</select>
<script type="text/javascript">
fxwlmgrid.Lists["x_bh"].Options = <%= ew_IIf(IsArray(xwlm.bh.EditValue), ew_ArrayToJson(xwlm.bh.EditValue, 1), "[]") %>;
</script>
<% End If %>
<input type="hidden" data-field="x_bh" name="o<%= xwlm_grid.RowIndex %>_bh" id="o<%= xwlm_grid.RowIndex %>_bh" value="<%= Server.HTMLEncode(xwlm.bh.OldValue&"") %>">
<% End If %>
<% If xwlm.RowType = EW_ROWTYPE_EDIT Then ' Edit Record %>
<% If xwlm.bh.SessionValue <> "" Then %>
<span<%= xwlm.bh.ViewAttributes %>>
<%= xwlm.bh.ListViewValue %>
</span>
<input type="hidden" id="x<%= xwlm_grid.RowIndex %>_bh" name="x<%= xwlm_grid.RowIndex %>_bh" value="<%= ew_HtmlEncode(xwlm.bh.CurrentValue) %>">
<% Else %>
<select data-field="x_bh" id="x<%= xwlm_grid.RowIndex %>_bh" name="x<%= xwlm_grid.RowIndex %>_bh"<%= xwlm.bh.EditAttributes %>>
<%
emptywrk = True
If IsArray(xwlm.bh.EditValue) Then
	arwrk = xwlm.bh.EditValue
	For rowcntwrk = 0 To UBound(arwrk, 2)
		If arwrk(0, rowcntwrk)&"" = xwlm.bh.CurrentValue&"" Then
			selwrk = " selected=""selected"""
			emptywrk = False
		Else
			selwrk = ""
		End If
%>
<option value="<%= Server.HtmlEncode(arwrk(0, rowcntwrk)&"") %>"<%= selwrk %>>
<%= arwrk(1, rowcntwrk) %>
</option>
<%
	Next
End If
If emptywrk Then xwlm.bh.OldValue = ""
%>
</select>
<script type="text/javascript">
fxwlmgrid.Lists["x_bh"].Options = <%= ew_IIf(IsArray(xwlm.bh.EditValue), ew_ArrayToJson(xwlm.bh.EditValue, 1), "[]") %>;
</script>
<% End If %>
<% End If %>
<% If xwlm.RowType = EW_ROWTYPE_VIEW Then ' View Record %>
<span<%= xwlm.bh.ViewAttributes %>>
<%= xwlm.bh.ListViewValue %>
</span>
<input type="hidden" data-field="x_bh" name="x<%= xwlm_grid.RowIndex %>_bh" id="x<%= xwlm_grid.RowIndex %>_bh" value="<%= Server.HTMLEncode(xwlm.bh.FormValue&"") %>">
<input type="hidden" data-field="x_bh" name="o<%= xwlm_grid.RowIndex %>_bh" id="o<%= xwlm_grid.RowIndex %>_bh" value="<%= Server.HTMLEncode(xwlm.bh.OldValue&"") %>">
<% End If %>
</td>
	<% End If %>
	<% If xwlm.lmmc.Visible Then ' lmmc %>
		<td<%= xwlm.lmmc.CellAttributes %>>
<% If xwlm.RowType = EW_ROWTYPE_ADD Then ' Add Record %>
<span id="el<%= xwlm_grid.RowCnt %>_xwlm_lmmc" class="control-group xwlm_lmmc">
<input type="text" data-field="x_lmmc" name="x<%= xwlm_grid.RowIndex %>_lmmc" id="x<%= xwlm_grid.RowIndex %>_lmmc" size="30" maxlength="50" placeholder="<%= xwlm.lmmc.PlaceHolder %>" value="<%= xwlm.lmmc.EditValue %>"<%= xwlm.lmmc.EditAttributes %>>
</span>
<input type="hidden" data-field="x_lmmc" name="o<%= xwlm_grid.RowIndex %>_lmmc" id="o<%= xwlm_grid.RowIndex %>_lmmc" value="<%= Server.HTMLEncode(xwlm.lmmc.OldValue&"") %>">
<% End If %>
<% If xwlm.RowType = EW_ROWTYPE_EDIT Then ' Edit Record %>
<span id="el<%= xwlm_grid.RowCnt %>_xwlm_lmmc" class="control-group xwlm_lmmc">
<input type="text" data-field="x_lmmc" name="x<%= xwlm_grid.RowIndex %>_lmmc" id="x<%= xwlm_grid.RowIndex %>_lmmc" size="30" maxlength="50" placeholder="<%= xwlm.lmmc.PlaceHolder %>" value="<%= xwlm.lmmc.EditValue %>"<%= xwlm.lmmc.EditAttributes %>>
</span>
<% End If %>
<% If xwlm.RowType = EW_ROWTYPE_VIEW Then ' View Record %>
<span<%= xwlm.lmmc.ViewAttributes %>>
<%= xwlm.lmmc.ListViewValue %>
</span>
<input type="hidden" data-field="x_lmmc" name="x<%= xwlm_grid.RowIndex %>_lmmc" id="x<%= xwlm_grid.RowIndex %>_lmmc" value="<%= Server.HTMLEncode(xwlm.lmmc.FormValue&"") %>">
<input type="hidden" data-field="x_lmmc" name="o<%= xwlm_grid.RowIndex %>_lmmc" id="o<%= xwlm_grid.RowIndex %>_lmmc" value="<%= Server.HTMLEncode(xwlm.lmmc.OldValue&"") %>">
<% End If %>
</td>
	<% End If %>
	<% If xwlm.lmmc2.Visible Then ' lmmc2 %>
		<td<%= xwlm.lmmc2.CellAttributes %>>
<% If xwlm.RowType = EW_ROWTYPE_ADD Then ' Add Record %>
<span id="el<%= xwlm_grid.RowCnt %>_xwlm_lmmc2" class="control-group xwlm_lmmc2">
<input type="text" data-field="x_lmmc2" name="x<%= xwlm_grid.RowIndex %>_lmmc2" id="x<%= xwlm_grid.RowIndex %>_lmmc2" size="30" maxlength="50" placeholder="<%= xwlm.lmmc2.PlaceHolder %>" value="<%= xwlm.lmmc2.EditValue %>"<%= xwlm.lmmc2.EditAttributes %>>
</span>
<input type="hidden" data-field="x_lmmc2" name="o<%= xwlm_grid.RowIndex %>_lmmc2" id="o<%= xwlm_grid.RowIndex %>_lmmc2" value="<%= Server.HTMLEncode(xwlm.lmmc2.OldValue&"") %>">
<% End If %>
<% If xwlm.RowType = EW_ROWTYPE_EDIT Then ' Edit Record %>
<span id="el<%= xwlm_grid.RowCnt %>_xwlm_lmmc2" class="control-group xwlm_lmmc2">
<input type="text" data-field="x_lmmc2" name="x<%= xwlm_grid.RowIndex %>_lmmc2" id="x<%= xwlm_grid.RowIndex %>_lmmc2" size="30" maxlength="50" placeholder="<%= xwlm.lmmc2.PlaceHolder %>" value="<%= xwlm.lmmc2.EditValue %>"<%= xwlm.lmmc2.EditAttributes %>>
</span>
<% End If %>
<% If xwlm.RowType = EW_ROWTYPE_VIEW Then ' View Record %>
<span<%= xwlm.lmmc2.ViewAttributes %>>
<%= xwlm.lmmc2.ListViewValue %>
</span>
<input type="hidden" data-field="x_lmmc2" name="x<%= xwlm_grid.RowIndex %>_lmmc2" id="x<%= xwlm_grid.RowIndex %>_lmmc2" value="<%= Server.HTMLEncode(xwlm.lmmc2.FormValue&"") %>">
<input type="hidden" data-field="x_lmmc2" name="o<%= xwlm_grid.RowIndex %>_lmmc2" id="o<%= xwlm_grid.RowIndex %>_lmmc2" value="<%= Server.HTMLEncode(xwlm.lmmc2.OldValue&"") %>">
<% End If %>
</td>
	<% End If %>
	<% If xwlm.px.Visible Then ' px %>
		<td<%= xwlm.px.CellAttributes %>>
<% If xwlm.RowType = EW_ROWTYPE_ADD Then ' Add Record %>
<span id="el<%= xwlm_grid.RowCnt %>_xwlm_px" class="control-group xwlm_px">
<input type="text" data-field="x_px" name="x<%= xwlm_grid.RowIndex %>_px" id="x<%= xwlm_grid.RowIndex %>_px" size="30" maxlength="50" placeholder="<%= xwlm.px.PlaceHolder %>" value="<%= xwlm.px.EditValue %>"<%= xwlm.px.EditAttributes %>>
</span>
<input type="hidden" data-field="x_px" name="o<%= xwlm_grid.RowIndex %>_px" id="o<%= xwlm_grid.RowIndex %>_px" value="<%= Server.HTMLEncode(xwlm.px.OldValue&"") %>">
<% End If %>
<% If xwlm.RowType = EW_ROWTYPE_EDIT Then ' Edit Record %>
<span id="el<%= xwlm_grid.RowCnt %>_xwlm_px" class="control-group xwlm_px">
<input type="text" data-field="x_px" name="x<%= xwlm_grid.RowIndex %>_px" id="x<%= xwlm_grid.RowIndex %>_px" size="30" maxlength="50" placeholder="<%= xwlm.px.PlaceHolder %>" value="<%= xwlm.px.EditValue %>"<%= xwlm.px.EditAttributes %>>
</span>
<% End If %>
<% If xwlm.RowType = EW_ROWTYPE_VIEW Then ' View Record %>
<span<%= xwlm.px.ViewAttributes %>>
<%= xwlm.px.ListViewValue %>
</span>
<input type="hidden" data-field="x_px" name="x<%= xwlm_grid.RowIndex %>_px" id="x<%= xwlm_grid.RowIndex %>_px" value="<%= Server.HTMLEncode(xwlm.px.FormValue&"") %>">
<input type="hidden" data-field="x_px" name="o<%= xwlm_grid.RowIndex %>_px" id="o<%= xwlm_grid.RowIndex %>_px" value="<%= Server.HTMLEncode(xwlm.px.OldValue&"") %>">
<% End If %>
</td>
	<% End If %>
	<% If xwlm.urllb.Visible Then ' urllb %>
		<td<%= xwlm.urllb.CellAttributes %>>
<% If xwlm.RowType = EW_ROWTYPE_ADD Then ' Add Record %>
<span id="el<%= xwlm_grid.RowCnt %>_xwlm_urllb" class="control-group xwlm_urllb">
<div id="tp_x<%= xwlm_grid.RowIndex %>_urllb" class="<%= EW_ITEM_TEMPLATE_CLASSNAME %>"><input type="radio" name="x<%= xwlm_grid.RowIndex %>_urllb" id="x<%= xwlm_grid.RowIndex %>_urllb" value="{value}"<%= xwlm.urllb.EditAttributes %>></div>
<div id="dsl_x<%= xwlm_grid.RowIndex %>_urllb" data-repeatcolumn="5" class="ewItemList">
<%
emptywrk = True
arwrk = xwlm.urllb.EditValue
If IsArray(arwrk) Then
	rowswrk = UBound(arwrk, 2)	
	For rowcntwrk = 0 To rowswrk
		If xwlm.urllb.CurrentValue&"" = arwrk(0, rowcntwrk)&"" Then
			selwrk = " checked=""checked"""
			emptywrk = False
		Else
			selwrk = ""
		End If

		' Note: No spacing within the LABEL tag
%>
<%= ew_RepeatColumnTable(rowswrk, rowcntwrk, 5, 1) %>
<label class="radio"><input type="radio" data-field="x_urllb" name="x<%= xwlm_grid.RowIndex %>_urllb" id="x<%= xwlm_grid.RowIndex %>_urllb_<%= rowcntwrk %>" value="<%= Server.HtmlEncode(arwrk(0, rowcntwrk)&"") %>"<%= selwrk %><%= xwlm.urllb.EditAttributes %>><%= arwrk(1, rowcntwrk) %></label>
<%= ew_RepeatColumnTable(rowswrk, rowcntwrk, 5, 2) %>
<%
	Next
End If
If emptywrk Then xwlm.urllb.OldValue = ""
%>
</div>
</span>
<input type="hidden" data-field="x_urllb" name="o<%= xwlm_grid.RowIndex %>_urllb" id="o<%= xwlm_grid.RowIndex %>_urllb" value="<%= Server.HTMLEncode(xwlm.urllb.OldValue&"") %>">
<% End If %>
<% If xwlm.RowType = EW_ROWTYPE_EDIT Then ' Edit Record %>
<span id="el<%= xwlm_grid.RowCnt %>_xwlm_urllb" class="control-group xwlm_urllb">
<div id="tp_x<%= xwlm_grid.RowIndex %>_urllb" class="<%= EW_ITEM_TEMPLATE_CLASSNAME %>"><input type="radio" name="x<%= xwlm_grid.RowIndex %>_urllb" id="x<%= xwlm_grid.RowIndex %>_urllb" value="{value}"<%= xwlm.urllb.EditAttributes %>></div>
<div id="dsl_x<%= xwlm_grid.RowIndex %>_urllb" data-repeatcolumn="5" class="ewItemList">
<%
emptywrk = True
arwrk = xwlm.urllb.EditValue
If IsArray(arwrk) Then
	rowswrk = UBound(arwrk, 2)	
	For rowcntwrk = 0 To rowswrk
		If xwlm.urllb.CurrentValue&"" = arwrk(0, rowcntwrk)&"" Then
			selwrk = " checked=""checked"""
			emptywrk = False
		Else
			selwrk = ""
		End If

		' Note: No spacing within the LABEL tag
%>
<%= ew_RepeatColumnTable(rowswrk, rowcntwrk, 5, 1) %>
<label class="radio"><input type="radio" data-field="x_urllb" name="x<%= xwlm_grid.RowIndex %>_urllb" id="x<%= xwlm_grid.RowIndex %>_urllb_<%= rowcntwrk %>" value="<%= Server.HtmlEncode(arwrk(0, rowcntwrk)&"") %>"<%= selwrk %><%= xwlm.urllb.EditAttributes %>><%= arwrk(1, rowcntwrk) %></label>
<%= ew_RepeatColumnTable(rowswrk, rowcntwrk, 5, 2) %>
<%
	Next
End If
If emptywrk Then xwlm.urllb.OldValue = ""
%>
</div>
</span>
<% End If %>
<% If xwlm.RowType = EW_ROWTYPE_VIEW Then ' View Record %>
<span<%= xwlm.urllb.ViewAttributes %>>
<%= xwlm.urllb.ListViewValue %>
</span>
<input type="hidden" data-field="x_urllb" name="x<%= xwlm_grid.RowIndex %>_urllb" id="x<%= xwlm_grid.RowIndex %>_urllb" value="<%= Server.HTMLEncode(xwlm.urllb.FormValue&"") %>">
<input type="hidden" data-field="x_urllb" name="o<%= xwlm_grid.RowIndex %>_urllb" id="o<%= xwlm_grid.RowIndex %>_urllb" value="<%= Server.HTMLEncode(xwlm.urllb.OldValue&"") %>">
<% End If %>
</td>
	<% End If %>
<%

' Render list options (body, right)
xwlm_grid.ListOptions.Render "body", "right", xwlm_grid.RowCnt, "", "", ""
%>
	</tr>
<% If xwlm.RowType = EW_ROWTYPE_ADD Or xwlm.RowType = EW_ROWTYPE_EDIT Then %>
<script type="text/javascript">
fxwlmgrid.UpdateOpts(<%= xwlm_grid.RowIndex %>);
</script>
<% End If %>
<%
	End If
	End If ' End delete row checking
	If xwlm.CurrentAction <> "gridadd" Or xwlm.CurrentMode = "copy" Then
		If Not xwlm_grid.Recordset.Eof Then xwlm_grid.Recordset.MoveNext()
	End If
Loop
%>
<%
	If xwlm.CurrentMode = "add" Or xwlm.CurrentMode = "copy" Or xwlm.CurrentMode = "edit" Then
		xwlm_grid.RowIndex = "$rowindex$"
		xwlm_grid.LoadDefaultValues()

		' Set row properties
		Call xwlm.ResetAttrs()
		xwlm.RowAttrs.AddAttributes Array(Array("data-rowindex", xwlm_grid.RowIndex), Array("id", "r0_xwlm"), Array("data-rowtype", EW_ROWTYPE_ADD))
		xwlm.RowAttrs.UpdateAttribute "class", "ewTemplate"
		xwlm.RowType = EW_ROWTYPE_ADD

		' Render row
		Call xwlm_grid.RenderRow()

		' Render list options
		Call xwlm_grid.RenderListOptions()
		xwlm_grid.StartRowCnt = 0
%>
	<tr<%= xwlm.RowAttributes %>>
<%

' Render list options (body, left)
xwlm_grid.ListOptions.Render "body", "left", xwlm_grid.RowIndex, "", "", ""
%>
	<% If xwlm.lmid.Visible Then ' lmid %>
		<td>
<% If xwlm.CurrentAction <> "F" Then %>
<% Else %>
<span id="el$rowindex$_xwlm_lmid" class="control-group xwlm_lmid">
<span<%= xwlm.lmid.ViewAttributes %>>
<%= xwlm.lmid.ViewValue %>
</span>
</span>
<input type="hidden" data-field="x_lmid" name="x<%= xwlm_grid.RowIndex %>_lmid" id="x<%= xwlm_grid.RowIndex %>_lmid" value="<%= Server.HTMLEncode(xwlm.lmid.FormValue&"") %>">
<% End If %>
<input type="hidden" data-field="x_lmid" name="o<%= xwlm_grid.RowIndex %>_lmid" id="o<%= xwlm_grid.RowIndex %>_lmid" value="<%= Server.HTMLEncode(xwlm.lmid.OldValue&"") %>">
</td>
	<% End If %>
	<% If xwlm.bh.Visible Then ' bh %>
		<td>
<% If xwlm.CurrentAction <> "F" Then %>
<% If xwlm.bh.SessionValue <> "" Then %>
<span<%= xwlm.bh.ViewAttributes %>>
<%= xwlm.bh.ListViewValue %>
</span>
<input type="hidden" id="x<%= xwlm_grid.RowIndex %>_bh" name="x<%= xwlm_grid.RowIndex %>_bh" value="<%= ew_HtmlEncode(xwlm.bh.CurrentValue) %>">
<% Else %>
<select data-field="x_bh" id="x<%= xwlm_grid.RowIndex %>_bh" name="x<%= xwlm_grid.RowIndex %>_bh"<%= xwlm.bh.EditAttributes %>>
<%
emptywrk = True
If IsArray(xwlm.bh.EditValue) Then
	arwrk = xwlm.bh.EditValue
	For rowcntwrk = 0 To UBound(arwrk, 2)
		If arwrk(0, rowcntwrk)&"" = xwlm.bh.CurrentValue&"" Then
			selwrk = " selected=""selected"""
			emptywrk = False
		Else
			selwrk = ""
		End If
%>
<option value="<%= Server.HtmlEncode(arwrk(0, rowcntwrk)&"") %>"<%= selwrk %>>
<%= arwrk(1, rowcntwrk) %>
</option>
<%
	Next
End If
If emptywrk Then xwlm.bh.OldValue = ""
%>
</select>
<script type="text/javascript">
fxwlmgrid.Lists["x_bh"].Options = <%= ew_IIf(IsArray(xwlm.bh.EditValue), ew_ArrayToJson(xwlm.bh.EditValue, 1), "[]") %>;
</script>
<% End If %>
<% Else %>
<span<%= xwlm.bh.ViewAttributes %>>
<%= xwlm.bh.ViewValue %>
</span>
<input type="hidden" data-field="x_bh" name="x<%= xwlm_grid.RowIndex %>_bh" id="x<%= xwlm_grid.RowIndex %>_bh" value="<%= Server.HTMLEncode(xwlm.bh.FormValue&"") %>">
<% End If %>
<input type="hidden" data-field="x_bh" name="o<%= xwlm_grid.RowIndex %>_bh" id="o<%= xwlm_grid.RowIndex %>_bh" value="<%= Server.HTMLEncode(xwlm.bh.OldValue&"") %>">
</td>
	<% End If %>
	<% If xwlm.lmmc.Visible Then ' lmmc %>
		<td>
<% If xwlm.CurrentAction <> "F" Then %>
<span id="el$rowindex$_xwlm_lmmc" class="control-group xwlm_lmmc">
<input type="text" data-field="x_lmmc" name="x<%= xwlm_grid.RowIndex %>_lmmc" id="x<%= xwlm_grid.RowIndex %>_lmmc" size="30" maxlength="50" placeholder="<%= xwlm.lmmc.PlaceHolder %>" value="<%= xwlm.lmmc.EditValue %>"<%= xwlm.lmmc.EditAttributes %>>
</span>
<% Else %>
<span id="el$rowindex$_xwlm_lmmc" class="control-group xwlm_lmmc">
<span<%= xwlm.lmmc.ViewAttributes %>>
<%= xwlm.lmmc.ViewValue %>
</span>
</span>
<input type="hidden" data-field="x_lmmc" name="x<%= xwlm_grid.RowIndex %>_lmmc" id="x<%= xwlm_grid.RowIndex %>_lmmc" value="<%= Server.HTMLEncode(xwlm.lmmc.FormValue&"") %>">
<% End If %>
<input type="hidden" data-field="x_lmmc" name="o<%= xwlm_grid.RowIndex %>_lmmc" id="o<%= xwlm_grid.RowIndex %>_lmmc" value="<%= Server.HTMLEncode(xwlm.lmmc.OldValue&"") %>">
</td>
	<% End If %>
	<% If xwlm.lmmc2.Visible Then ' lmmc2 %>
		<td>
<% If xwlm.CurrentAction <> "F" Then %>
<span id="el$rowindex$_xwlm_lmmc2" class="control-group xwlm_lmmc2">
<input type="text" data-field="x_lmmc2" name="x<%= xwlm_grid.RowIndex %>_lmmc2" id="x<%= xwlm_grid.RowIndex %>_lmmc2" size="30" maxlength="50" placeholder="<%= xwlm.lmmc2.PlaceHolder %>" value="<%= xwlm.lmmc2.EditValue %>"<%= xwlm.lmmc2.EditAttributes %>>
</span>
<% Else %>
<span id="el$rowindex$_xwlm_lmmc2" class="control-group xwlm_lmmc2">
<span<%= xwlm.lmmc2.ViewAttributes %>>
<%= xwlm.lmmc2.ViewValue %>
</span>
</span>
<input type="hidden" data-field="x_lmmc2" name="x<%= xwlm_grid.RowIndex %>_lmmc2" id="x<%= xwlm_grid.RowIndex %>_lmmc2" value="<%= Server.HTMLEncode(xwlm.lmmc2.FormValue&"") %>">
<% End If %>
<input type="hidden" data-field="x_lmmc2" name="o<%= xwlm_grid.RowIndex %>_lmmc2" id="o<%= xwlm_grid.RowIndex %>_lmmc2" value="<%= Server.HTMLEncode(xwlm.lmmc2.OldValue&"") %>">
</td>
	<% End If %>
	<% If xwlm.px.Visible Then ' px %>
		<td>
<% If xwlm.CurrentAction <> "F" Then %>
<span id="el$rowindex$_xwlm_px" class="control-group xwlm_px">
<input type="text" data-field="x_px" name="x<%= xwlm_grid.RowIndex %>_px" id="x<%= xwlm_grid.RowIndex %>_px" size="30" maxlength="50" placeholder="<%= xwlm.px.PlaceHolder %>" value="<%= xwlm.px.EditValue %>"<%= xwlm.px.EditAttributes %>>
</span>
<% Else %>
<span id="el$rowindex$_xwlm_px" class="control-group xwlm_px">
<span<%= xwlm.px.ViewAttributes %>>
<%= xwlm.px.ViewValue %>
</span>
</span>
<input type="hidden" data-field="x_px" name="x<%= xwlm_grid.RowIndex %>_px" id="x<%= xwlm_grid.RowIndex %>_px" value="<%= Server.HTMLEncode(xwlm.px.FormValue&"") %>">
<% End If %>
<input type="hidden" data-field="x_px" name="o<%= xwlm_grid.RowIndex %>_px" id="o<%= xwlm_grid.RowIndex %>_px" value="<%= Server.HTMLEncode(xwlm.px.OldValue&"") %>">
</td>
	<% End If %>
	<% If xwlm.urllb.Visible Then ' urllb %>
		<td>
<% If xwlm.CurrentAction <> "F" Then %>
<span id="el$rowindex$_xwlm_urllb" class="control-group xwlm_urllb">
<div id="tp_x<%= xwlm_grid.RowIndex %>_urllb" class="<%= EW_ITEM_TEMPLATE_CLASSNAME %>"><input type="radio" name="x<%= xwlm_grid.RowIndex %>_urllb" id="x<%= xwlm_grid.RowIndex %>_urllb" value="{value}"<%= xwlm.urllb.EditAttributes %>></div>
<div id="dsl_x<%= xwlm_grid.RowIndex %>_urllb" data-repeatcolumn="5" class="ewItemList">
<%
emptywrk = True
arwrk = xwlm.urllb.EditValue
If IsArray(arwrk) Then
	rowswrk = UBound(arwrk, 2)	
	For rowcntwrk = 0 To rowswrk
		If xwlm.urllb.CurrentValue&"" = arwrk(0, rowcntwrk)&"" Then
			selwrk = " checked=""checked"""
			emptywrk = False
		Else
			selwrk = ""
		End If

		' Note: No spacing within the LABEL tag
%>
<%= ew_RepeatColumnTable(rowswrk, rowcntwrk, 5, 1) %>
<label class="radio"><input type="radio" data-field="x_urllb" name="x<%= xwlm_grid.RowIndex %>_urllb" id="x<%= xwlm_grid.RowIndex %>_urllb_<%= rowcntwrk %>" value="<%= Server.HtmlEncode(arwrk(0, rowcntwrk)&"") %>"<%= selwrk %><%= xwlm.urllb.EditAttributes %>><%= arwrk(1, rowcntwrk) %></label>
<%= ew_RepeatColumnTable(rowswrk, rowcntwrk, 5, 2) %>
<%
	Next
End If
If emptywrk Then xwlm.urllb.OldValue = ""
%>
</div>
</span>
<% Else %>
<span id="el$rowindex$_xwlm_urllb" class="control-group xwlm_urllb">
<span<%= xwlm.urllb.ViewAttributes %>>
<%= xwlm.urllb.ViewValue %>
</span>
</span>
<input type="hidden" data-field="x_urllb" name="x<%= xwlm_grid.RowIndex %>_urllb" id="x<%= xwlm_grid.RowIndex %>_urllb" value="<%= Server.HTMLEncode(xwlm.urllb.FormValue&"") %>">
<% End If %>
<input type="hidden" data-field="x_urllb" name="o<%= xwlm_grid.RowIndex %>_urllb" id="o<%= xwlm_grid.RowIndex %>_urllb" value="<%= Server.HTMLEncode(xwlm.urllb.OldValue&"") %>">
</td>
	<% End If %>
<%

' Render list options (body, right)
xwlm_grid.ListOptions.Render "body", "right", xwlm_grid.RowCnt, "", "", ""
%>
<script type="text/javascript">
fxwlmgrid.UpdateOpts(<%= xwlm_grid.RowIndex %>);
</script>
	</tr>
<%
End If
%>
</tbody>
</table>
<% If xwlm.CurrentMode = "add" Or xwlm.CurrentMode = "copy" Then %>
<input type="hidden" name="a_list" id="a_list" value="gridinsert">
<input type="hidden" name="<%= xwlm_grid.FormKeyCountName %>" id="<%= xwlm_grid.FormKeyCountName %>" value="<%= xwlm_grid.KeyCount %>">
<%= xwlm_grid.MultiSelectKey %>
<% End If %>
<% If xwlm.CurrentMode = "edit" Then %>
<input type="hidden" name="a_list" id="a_list" value="gridupdate">
<input type="hidden" name="<%= xwlm_grid.FormKeyCountName %>" id="<%= xwlm_grid.FormKeyCountName %>" value="<%= xwlm_grid.KeyCount %>">
<%= xwlm_grid.MultiSelectKey %>
<% End If %>
<% If xwlm.CurrentMode = "" Then %>
<input type="hidden" name="a_list" id="a_list" value="">
<% End If %>
<input type="hidden" name="detailpage" value="fxwlmgrid">
</div>
<%

' Close recordset and connection
xwlm_grid.Recordset.Close
Set xwlm_grid.Recordset = Nothing
%>
<% If xwlm_grid.ShowOtherOptions Then %>
<div class="ewGridLowerPanel ewListOtherOptions">
<%
	xwlm_grid.AddEditOptions.Render "body", "bottom", "", "", "", ""
%>
</div>
<% End If %>
</div>
</td></tr></table>
<% If xwlm.Export = "" Then %>
<script type="text/javascript">
fxwlmgrid.Init();
<% If EW_MOBILE_REFLOW And ew_IsMobile() Then %>
ew_Reflow();
<% End If %>
</script>
<% End If %>
<%
xwlm_grid.ShowPageFooter()
If EW_DEBUG_ENABLED Then Response.Write ew_DebugMsg()
%>
<%

' Drop page object
Set xwlm_grid = Nothing
%>
