<% Session.Timeout = 900 %>
<%

' Define page object
Dim xwfb_grid
Set xwfb_grid = New cxwfb_grid
Set Grid = xwfb_grid

' Page init processing
xwfb_grid.Page_Init()

' Page main processing
xwfb_grid.Page_Main()

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

' Page Rendering event
xwfb_grid.Page_Render()
%>
<% If xwfb.Export = "" Then %>
<script type="text/javascript">
// Page object
var xwfb_grid = new ew_Page("xwfb_grid");
xwfb_grid.PageID = "grid"; // Page ID
var EW_PAGE_ID = xwfb_grid.PageID; // For backward compatibility
// Form object
var fxwfbgrid = new ew_Form("fxwfbgrid");
fxwfbgrid.FormKeyCountName = '<%= xwfb_grid.FormKeyCountName %>';
// Validate form
fxwfbgrid.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 + "_bh");
			if (elm && !ew_HasValue(elm))
				return this.OnError(elm, ewLanguage.Phrase("EnterRequiredField") + " - <%= ew_JsEncode2(xwfb.bh.FldCaption) %>");
			elm = this.GetElements("x" + infix + "_xwbt");
			if (elm && !ew_HasValue(elm))
				return this.OnError(elm, ewLanguage.Phrase("EnterRequiredField") + " - <%= ew_JsEncode2(xwfb.xwbt.FldCaption) %>");
			elm = this.GetElements("x" + infix + "_fbsj");
			if (elm && !ew_HasValue(elm))
				return this.OnError(elm, ewLanguage.Phrase("EnterRequiredField") + " - <%= ew_JsEncode2(xwfb.fbsj.FldCaption) %>");
			elm = this.GetElements("x" + infix + "_fbsj");
			if (elm && !ew_CheckDate(elm.value))
				return this.OnError(elm, "<%= ew_JsEncode2(xwfb.fbsj.FldErrMsg) %>");
			elm = this.GetElements("x" + infix + "_px");
			if (elm && !ew_CheckInteger(elm.value))
				return this.OnError(elm, "<%= ew_JsEncode2(xwfb.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
fxwfbgrid.EmptyRow = function(infix) {
	var fobj = this.Form;
	if (ew_ValueChanged(fobj, infix, "bh", false)) return false;
	if (ew_ValueChanged(fobj, infix, "lmid", false)) return false;
	if (ew_ValueChanged(fobj, infix, "xwbt", false)) return false;
	if (ew_ValueChanged(fobj, infix, "fbsj", false)) return false;
	if (ew_ValueChanged(fobj, infix, "ishome", false)) return false;
	if (ew_ValueChanged(fobj, infix, "px", false)) return false;
	if (ew_ValueChanged(fobj, infix, "newkey", false)) return false;
	if (ew_ValueChanged(fobj, infix, "tags", false)) return false;
	return true;
}
// Form_CustomValidate event
fxwfbgrid.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 %>
fxwfbgrid.ValidateRequired = true; // Use JavaScript validation
<% Else %>
fxwfbgrid.ValidateRequired = false; // No JavaScript validation
<% End If %>
// Dynamic selection lists
fxwfbgrid.Lists["x_bh"] = {"LinkField":"x_bh","Ajax":null,"AutoFill":false,"DisplayFields":["x_bhmc","","",""],"ParentFields":[],"FilterFields":[],"Options":[]};
fxwfbgrid.Lists["x_lmid"] = {"LinkField":"x_lmid","Ajax":null,"AutoFill":false,"DisplayFields":["x_lmmc","","",""],"ParentFields":["x_bh"],"FilterFields":["x_bh"],"Options":[]};
// Form object for search
</script>
<% End If %>
<%
If xwfb.CurrentAction = "gridadd" Then
	If xwfb.CurrentMode <> "copy" Then xwfb.CurrentFilter = "0=1"
End If

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

' Render list options (header, left)
xwfb_grid.ListOptions.Render "header", "left", "", "", "", ""
%>
<% If xwfb.id.Visible Then ' id %>
	<% If xwfb.SortUrl(xwfb.id) = "" Then %>
		<td><div id="elh_xwfb_id" class="xwfb_id"><div class="ewTableHeaderCaption"><%= xwfb.id.FldCaption %></div></div></td>
	<% Else %>
		<td><div><div id="elh_xwfb_id" class="xwfb_id">
			<div class="ewTableHeaderBtn"><span class="ewTableHeaderCaption"><%= xwfb.id.FldCaption %></span><span class="ewTableHeaderSort"><% If xwfb.id.Sort = "ASC" Then %><span class="caret ewSortUp"></span><% ElseIf xwfb.id.Sort = "DESC" Then %><span class="caret"></span><% End If %></span></div>
        </div></div></td>
	<% End If %>
<% End If %>		
<% If xwfb.bh.Visible Then ' bh %>
	<% If xwfb.SortUrl(xwfb.bh) = "" Then %>
		<td><div id="elh_xwfb_bh" class="xwfb_bh"><div class="ewTableHeaderCaption"><%= xwfb.bh.FldCaption %></div></div></td>
	<% Else %>
		<td><div><div id="elh_xwfb_bh" class="xwfb_bh">
			<div class="ewTableHeaderBtn"><span class="ewTableHeaderCaption"><%= xwfb.bh.FldCaption %></span><span class="ewTableHeaderSort"><% If xwfb.bh.Sort = "ASC" Then %><span class="caret ewSortUp"></span><% ElseIf xwfb.bh.Sort = "DESC" Then %><span class="caret"></span><% End If %></span></div>
        </div></div></td>
	<% End If %>
<% End If %>		
<% If xwfb.lmid.Visible Then ' lmid %>
	<% If xwfb.SortUrl(xwfb.lmid) = "" Then %>
		<td><div id="elh_xwfb_lmid" class="xwfb_lmid"><div class="ewTableHeaderCaption"><%= xwfb.lmid.FldCaption %></div></div></td>
	<% Else %>
		<td><div><div id="elh_xwfb_lmid" class="xwfb_lmid">
			<div class="ewTableHeaderBtn"><span class="ewTableHeaderCaption"><%= xwfb.lmid.FldCaption %></span><span class="ewTableHeaderSort"><% If xwfb.lmid.Sort = "ASC" Then %><span class="caret ewSortUp"></span><% ElseIf xwfb.lmid.Sort = "DESC" Then %><span class="caret"></span><% End If %></span></div>
        </div></div></td>
	<% End If %>
<% End If %>		
<% If xwfb.xwbt.Visible Then ' xwbt %>
	<% If xwfb.SortUrl(xwfb.xwbt) = "" Then %>
		<td><div id="elh_xwfb_xwbt" class="xwfb_xwbt"><div class="ewTableHeaderCaption"><%= xwfb.xwbt.FldCaption %></div></div></td>
	<% Else %>
		<td><div><div id="elh_xwfb_xwbt" class="xwfb_xwbt">
			<div class="ewTableHeaderBtn"><span class="ewTableHeaderCaption"><%= xwfb.xwbt.FldCaption %></span><span class="ewTableHeaderSort"><% If xwfb.xwbt.Sort = "ASC" Then %><span class="caret ewSortUp"></span><% ElseIf xwfb.xwbt.Sort = "DESC" Then %><span class="caret"></span><% End If %></span></div>
        </div></div></td>
	<% End If %>
<% End If %>		
<% If xwfb.fbsj.Visible Then ' fbsj %>
	<% If xwfb.SortUrl(xwfb.fbsj) = "" Then %>
		<td><div id="elh_xwfb_fbsj" class="xwfb_fbsj"><div class="ewTableHeaderCaption"><%= xwfb.fbsj.FldCaption %></div></div></td>
	<% Else %>
		<td><div><div id="elh_xwfb_fbsj" class="xwfb_fbsj">
			<div class="ewTableHeaderBtn"><span class="ewTableHeaderCaption"><%= xwfb.fbsj.FldCaption %></span><span class="ewTableHeaderSort"><% If xwfb.fbsj.Sort = "ASC" Then %><span class="caret ewSortUp"></span><% ElseIf xwfb.fbsj.Sort = "DESC" Then %><span class="caret"></span><% End If %></span></div>
        </div></div></td>
	<% End If %>
<% End If %>		
<% If xwfb.ishome.Visible Then ' ishome %>
	<% If xwfb.SortUrl(xwfb.ishome) = "" Then %>
		<td><div id="elh_xwfb_ishome" class="xwfb_ishome"><div class="ewTableHeaderCaption"><%= xwfb.ishome.FldCaption %></div></div></td>
	<% Else %>
		<td><div><div id="elh_xwfb_ishome" class="xwfb_ishome">
			<div class="ewTableHeaderBtn"><span class="ewTableHeaderCaption"><%= xwfb.ishome.FldCaption %></span><span class="ewTableHeaderSort"><% If xwfb.ishome.Sort = "ASC" Then %><span class="caret ewSortUp"></span><% ElseIf xwfb.ishome.Sort = "DESC" Then %><span class="caret"></span><% End If %></span></div>
        </div></div></td>
	<% End If %>
<% End If %>		
<% If xwfb.px.Visible Then ' px %>
	<% If xwfb.SortUrl(xwfb.px) = "" Then %>
		<td><div id="elh_xwfb_px" class="xwfb_px"><div class="ewTableHeaderCaption"><%= xwfb.px.FldCaption %></div></div></td>
	<% Else %>
		<td><div><div id="elh_xwfb_px" class="xwfb_px">
			<div class="ewTableHeaderBtn"><span class="ewTableHeaderCaption"><%= xwfb.px.FldCaption %></span><span class="ewTableHeaderSort"><% If xwfb.px.Sort = "ASC" Then %><span class="caret ewSortUp"></span><% ElseIf xwfb.px.Sort = "DESC" Then %><span class="caret"></span><% End If %></span></div>
        </div></div></td>
	<% End If %>
<% End If %>		
<% If xwfb.newkey.Visible Then ' newkey %>
	<% If xwfb.SortUrl(xwfb.newkey) = "" Then %>
		<td><div id="elh_xwfb_newkey" class="xwfb_newkey"><div class="ewTableHeaderCaption"><%= xwfb.newkey.FldCaption %></div></div></td>
	<% Else %>
		<td><div><div id="elh_xwfb_newkey" class="xwfb_newkey">
			<div class="ewTableHeaderBtn"><span class="ewTableHeaderCaption"><%= xwfb.newkey.FldCaption %></span><span class="ewTableHeaderSort"><% If xwfb.newkey.Sort = "ASC" Then %><span class="caret ewSortUp"></span><% ElseIf xwfb.newkey.Sort = "DESC" Then %><span class="caret"></span><% End If %></span></div>
        </div></div></td>
	<% End If %>
<% End If %>		
<% If xwfb.tags.Visible Then ' tags %>
	<% If xwfb.SortUrl(xwfb.tags) = "" Then %>
		<td><div id="elh_xwfb_tags" class="xwfb_tags"><div class="ewTableHeaderCaption"><%= xwfb.tags.FldCaption %></div></div></td>
	<% Else %>
		<td><div><div id="elh_xwfb_tags" class="xwfb_tags">
			<div class="ewTableHeaderBtn"><span class="ewTableHeaderCaption"><%= xwfb.tags.FldCaption %></span><span class="ewTableHeaderSort"><% If xwfb.tags.Sort = "ASC" Then %><span class="caret ewSortUp"></span><% ElseIf xwfb.tags.Sort = "DESC" Then %><span class="caret"></span><% End If %></span></div>
        </div></div></td>
	<% End If %>
<% End If %>		
<%

' Render list options (header, right)
xwfb_grid.ListOptions.Render "header", "right", "", "", "", ""
%>
	</tr>
</thead>
<tbody><!-- Table body -->
<%
xwfb_grid.StartRec = 1
xwfb_grid.StopRec = xwfb_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(xwfb_grid.FormKeyCountName) And (xwfb.CurrentAction = "gridadd" Or xwfb.CurrentAction = "gridedit" Or xwfb.CurrentAction = "F") Then
		xwfb_grid.KeyCount = ObjForm.GetValue(xwfb_grid.FormKeyCountName)
		xwfb_grid.StopRec = xwfb_grid.StartRec + xwfb_grid.KeyCount - 1
	End If
End If

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

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

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

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

	' Set up row id / data-rowindex
	xwfb.RowAttrs.AddAttributes Array(Array("data-rowindex", xwfb_grid.RowCnt), Array("id", "r" & xwfb_grid.RowCnt & "_xwfb"), Array("data-rowtype", xwfb.RowType))

	' Render row
	Call xwfb_grid.RenderRow()

	' Render list options
	Call xwfb_grid.RenderListOptions()

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

' Render list options (body, left)
xwfb_grid.ListOptions.Render "body", "left", xwfb_grid.RowCnt, "", "", ""
%>
	<% If xwfb.id.Visible Then ' id %>
		<td<%= xwfb.id.CellAttributes %>>
<% If xwfb.RowType = EW_ROWTYPE_ADD Then ' Add Record %>
<input type="hidden" data-field="x_id" name="o<%= xwfb_grid.RowIndex %>_id" id="o<%= xwfb_grid.RowIndex %>_id" value="<%= Server.HTMLEncode(xwfb.id.OldValue&"") %>">
<% End If %>
<% If xwfb.RowType = EW_ROWTYPE_EDIT Then ' Edit Record %>
<span id="el<%= xwfb_grid.RowCnt %>_xwfb_id" class="control-group xwfb_id">
<span<%= xwfb.id.ViewAttributes %>>
<%= xwfb.id.EditValue %>
</span>
</span>
<input type="hidden" data-field="x_id" name="x<%= xwfb_grid.RowIndex %>_id" id="x<%= xwfb_grid.RowIndex %>_id" value="<%= Server.HTMLEncode(xwfb.id.CurrentValue&"") %>">
<% End If %>
<% If xwfb.RowType = EW_ROWTYPE_VIEW Then ' View Record %>
<span<%= xwfb.id.ViewAttributes %>>
<%= xwfb.id.ListViewValue %>
</span>
<input type="hidden" data-field="x_id" name="x<%= xwfb_grid.RowIndex %>_id" id="x<%= xwfb_grid.RowIndex %>_id" value="<%= Server.HTMLEncode(xwfb.id.FormValue&"") %>">
<input type="hidden" data-field="x_id" name="o<%= xwfb_grid.RowIndex %>_id" id="o<%= xwfb_grid.RowIndex %>_id" value="<%= Server.HTMLEncode(xwfb.id.OldValue&"") %>">
<% End If %>
<a id="<%= xwfb_grid.PageObjName & "_row_" & xwfb_grid.RowCnt %>"></a></td>
	<% End If %>
	<% If xwfb.bh.Visible Then ' bh %>
		<td<%= xwfb.bh.CellAttributes %>>
<% If xwfb.RowType = EW_ROWTYPE_ADD Then ' Add Record %>
<% If xwfb.bh.SessionValue <> "" Then %>
<span<%= xwfb.bh.ViewAttributes %>>
<%= xwfb.bh.ListViewValue %>
</span>
<input type="hidden" id="x<%= xwfb_grid.RowIndex %>_bh" name="x<%= xwfb_grid.RowIndex %>_bh" value="<%= ew_HtmlEncode(xwfb.bh.CurrentValue) %>">
<% Else %>
<% xwfb.bh.EditAttrs.UpdateAttribute "onchange", "ew_UpdateOpt.call(this, ['x" & xwfb_grid.RowIndex & "_lmid']);" %>
<select data-field="x_bh" id="x<%= xwfb_grid.RowIndex %>_bh" name="x<%= xwfb_grid.RowIndex %>_bh"<%= xwfb.bh.EditAttributes %>>
<%
emptywrk = True
If IsArray(xwfb.bh.EditValue) Then
	arwrk = xwfb.bh.EditValue
	For rowcntwrk = 0 To UBound(arwrk, 2)
		If arwrk(0, rowcntwrk)&"" = xwfb.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 xwfb.bh.OldValue = ""
%>
</select>
<script type="text/javascript">
fxwfbgrid.Lists["x_bh"].Options = <%= ew_IIf(IsArray(xwfb.bh.EditValue), ew_ArrayToJson(xwfb.bh.EditValue, 1), "[]") %>;
</script>
<% End If %>
<input type="hidden" data-field="x_bh" name="o<%= xwfb_grid.RowIndex %>_bh" id="o<%= xwfb_grid.RowIndex %>_bh" value="<%= Server.HTMLEncode(xwfb.bh.OldValue&"") %>">
<% End If %>
<% If xwfb.RowType = EW_ROWTYPE_EDIT Then ' Edit Record %>
<% If xwfb.bh.SessionValue <> "" Then %>
<span<%= xwfb.bh.ViewAttributes %>>
<%= xwfb.bh.ListViewValue %>
</span>
<input type="hidden" id="x<%= xwfb_grid.RowIndex %>_bh" name="x<%= xwfb_grid.RowIndex %>_bh" value="<%= ew_HtmlEncode(xwfb.bh.CurrentValue) %>">
<% Else %>
<% xwfb.bh.EditAttrs.UpdateAttribute "onchange", "ew_UpdateOpt.call(this, ['x" & xwfb_grid.RowIndex & "_lmid']);" %>
<select data-field="x_bh" id="x<%= xwfb_grid.RowIndex %>_bh" name="x<%= xwfb_grid.RowIndex %>_bh"<%= xwfb.bh.EditAttributes %>>
<%
emptywrk = True
If IsArray(xwfb.bh.EditValue) Then
	arwrk = xwfb.bh.EditValue
	For rowcntwrk = 0 To UBound(arwrk, 2)
		If arwrk(0, rowcntwrk)&"" = xwfb.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 xwfb.bh.OldValue = ""
%>
</select>
<script type="text/javascript">
fxwfbgrid.Lists["x_bh"].Options = <%= ew_IIf(IsArray(xwfb.bh.EditValue), ew_ArrayToJson(xwfb.bh.EditValue, 1), "[]") %>;
</script>
<% End If %>
<% End If %>
<% If xwfb.RowType = EW_ROWTYPE_VIEW Then ' View Record %>
<span<%= xwfb.bh.ViewAttributes %>>
<%= xwfb.bh.ListViewValue %>
</span>
<input type="hidden" data-field="x_bh" name="x<%= xwfb_grid.RowIndex %>_bh" id="x<%= xwfb_grid.RowIndex %>_bh" value="<%= Server.HTMLEncode(xwfb.bh.FormValue&"") %>">
<input type="hidden" data-field="x_bh" name="o<%= xwfb_grid.RowIndex %>_bh" id="o<%= xwfb_grid.RowIndex %>_bh" value="<%= Server.HTMLEncode(xwfb.bh.OldValue&"") %>">
<% End If %>
</td>
	<% End If %>
	<% If xwfb.lmid.Visible Then ' lmid %>
		<td<%= xwfb.lmid.CellAttributes %>>
<% If xwfb.RowType = EW_ROWTYPE_ADD Then ' Add Record %>
<% If xwfb.lmid.SessionValue <> "" Then %>
<span<%= xwfb.lmid.ViewAttributes %>>
<%= xwfb.lmid.ListViewValue %>
</span>
<input type="hidden" id="x<%= xwfb_grid.RowIndex %>_lmid" name="x<%= xwfb_grid.RowIndex %>_lmid" value="<%= ew_HtmlEncode(xwfb.lmid.CurrentValue) %>">
<% Else %>
<select data-field="x_lmid" id="x<%= xwfb_grid.RowIndex %>_lmid" name="x<%= xwfb_grid.RowIndex %>_lmid"<%= xwfb.lmid.EditAttributes %>>
<%
emptywrk = True
If IsArray(xwfb.lmid.EditValue) Then
	arwrk = xwfb.lmid.EditValue
	For rowcntwrk = 0 To UBound(arwrk, 2)
		If arwrk(0, rowcntwrk)&"" = xwfb.lmid.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 xwfb.lmid.OldValue = ""
%>
</select>
<script type="text/javascript">
fxwfbgrid.Lists["x_lmid"].Options = <%= ew_IIf(IsArray(xwfb.lmid.EditValue), ew_ArrayToJson(xwfb.lmid.EditValue, 1), "[]") %>;
</script>
<% End If %>
<input type="hidden" data-field="x_lmid" name="o<%= xwfb_grid.RowIndex %>_lmid" id="o<%= xwfb_grid.RowIndex %>_lmid" value="<%= Server.HTMLEncode(xwfb.lmid.OldValue&"") %>">
<% End If %>
<% If xwfb.RowType = EW_ROWTYPE_EDIT Then ' Edit Record %>
<% If xwfb.lmid.SessionValue <> "" Then %>
<span<%= xwfb.lmid.ViewAttributes %>>
<%= xwfb.lmid.ListViewValue %>
</span>
<input type="hidden" id="x<%= xwfb_grid.RowIndex %>_lmid" name="x<%= xwfb_grid.RowIndex %>_lmid" value="<%= ew_HtmlEncode(xwfb.lmid.CurrentValue) %>">
<% Else %>
<select data-field="x_lmid" id="x<%= xwfb_grid.RowIndex %>_lmid" name="x<%= xwfb_grid.RowIndex %>_lmid"<%= xwfb.lmid.EditAttributes %>>
<%
emptywrk = True
If IsArray(xwfb.lmid.EditValue) Then
	arwrk = xwfb.lmid.EditValue
	For rowcntwrk = 0 To UBound(arwrk, 2)
		If arwrk(0, rowcntwrk)&"" = xwfb.lmid.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 xwfb.lmid.OldValue = ""
%>
</select>
<script type="text/javascript">
fxwfbgrid.Lists["x_lmid"].Options = <%= ew_IIf(IsArray(xwfb.lmid.EditValue), ew_ArrayToJson(xwfb.lmid.EditValue, 1), "[]") %>;
</script>
<% End If %>
<% End If %>
<% If xwfb.RowType = EW_ROWTYPE_VIEW Then ' View Record %>
<span<%= xwfb.lmid.ViewAttributes %>>
<%= xwfb.lmid.ListViewValue %>
</span>
<input type="hidden" data-field="x_lmid" name="x<%= xwfb_grid.RowIndex %>_lmid" id="x<%= xwfb_grid.RowIndex %>_lmid" value="<%= Server.HTMLEncode(xwfb.lmid.FormValue&"") %>">
<input type="hidden" data-field="x_lmid" name="o<%= xwfb_grid.RowIndex %>_lmid" id="o<%= xwfb_grid.RowIndex %>_lmid" value="<%= Server.HTMLEncode(xwfb.lmid.OldValue&"") %>">
<% End If %>
</td>
	<% End If %>
	<% If xwfb.xwbt.Visible Then ' xwbt %>
		<td<%= xwfb.xwbt.CellAttributes %>>
<% If xwfb.RowType = EW_ROWTYPE_ADD Then ' Add Record %>
<span id="el<%= xwfb_grid.RowCnt %>_xwfb_xwbt" class="control-group xwfb_xwbt">
<input type="text" data-field="x_xwbt" name="x<%= xwfb_grid.RowIndex %>_xwbt" id="x<%= xwfb_grid.RowIndex %>_xwbt" size="30" maxlength="50" placeholder="<%= xwfb.xwbt.PlaceHolder %>" value="<%= xwfb.xwbt.EditValue %>"<%= xwfb.xwbt.EditAttributes %>>
</span>
<input type="hidden" data-field="x_xwbt" name="o<%= xwfb_grid.RowIndex %>_xwbt" id="o<%= xwfb_grid.RowIndex %>_xwbt" value="<%= Server.HTMLEncode(xwfb.xwbt.OldValue&"") %>">
<% End If %>
<% If xwfb.RowType = EW_ROWTYPE_EDIT Then ' Edit Record %>
<span id="el<%= xwfb_grid.RowCnt %>_xwfb_xwbt" class="control-group xwfb_xwbt">
<input type="text" data-field="x_xwbt" name="x<%= xwfb_grid.RowIndex %>_xwbt" id="x<%= xwfb_grid.RowIndex %>_xwbt" size="30" maxlength="50" placeholder="<%= xwfb.xwbt.PlaceHolder %>" value="<%= xwfb.xwbt.EditValue %>"<%= xwfb.xwbt.EditAttributes %>>
</span>
<% End If %>
<% If xwfb.RowType = EW_ROWTYPE_VIEW Then ' View Record %>
<span<%= xwfb.xwbt.ViewAttributes %>>
<%= xwfb.xwbt.ListViewValue %>
</span>
<input type="hidden" data-field="x_xwbt" name="x<%= xwfb_grid.RowIndex %>_xwbt" id="x<%= xwfb_grid.RowIndex %>_xwbt" value="<%= Server.HTMLEncode(xwfb.xwbt.FormValue&"") %>">
<input type="hidden" data-field="x_xwbt" name="o<%= xwfb_grid.RowIndex %>_xwbt" id="o<%= xwfb_grid.RowIndex %>_xwbt" value="<%= Server.HTMLEncode(xwfb.xwbt.OldValue&"") %>">
<% End If %>
</td>
	<% End If %>
	<% If xwfb.fbsj.Visible Then ' fbsj %>
		<td<%= xwfb.fbsj.CellAttributes %>>
<% If xwfb.RowType = EW_ROWTYPE_ADD Then ' Add Record %>
<span id="el<%= xwfb_grid.RowCnt %>_xwfb_fbsj" class="control-group xwfb_fbsj">
<input type="text" data-field="x_fbsj" name="x<%= xwfb_grid.RowIndex %>_fbsj" id="x<%= xwfb_grid.RowIndex %>_fbsj" placeholder="<%= xwfb.fbsj.PlaceHolder %>" value="<%= xwfb.fbsj.EditValue %>"<%= xwfb.fbsj.EditAttributes %>>
<% If Not xwfb.fbsj.ReadOnly And Not xwfb.fbsj.Disabled And xwfb.fbsj.EditAttrs.Item("readonly") = "" And xwfb.fbsj.EditAttrs.Item("disabled") = "" Then %>
<button id="cal_x<%= xwfb_grid.RowIndex %>_fbsj" name="cal_x<%= xwfb_grid.RowIndex %>_fbsj" class="btn" type="button"><img src="images/calendar.png" alt="<%= Language.Phrase("PickDate") %>" title="<%= Language.Phrase("PickDate") %>" style="border: 0;"></button><script type="text/javascript">
ew_CreateCalendar("fxwfbgrid", "x<%= xwfb_grid.RowIndex %>_fbsj", "%Y-%m-%d");
</script>
<% End If %>
</span>
<input type="hidden" data-field="x_fbsj" name="o<%= xwfb_grid.RowIndex %>_fbsj" id="o<%= xwfb_grid.RowIndex %>_fbsj" value="<%= Server.HTMLEncode(xwfb.fbsj.OldValue&"") %>">
<% End If %>
<% If xwfb.RowType = EW_ROWTYPE_EDIT Then ' Edit Record %>
<span id="el<%= xwfb_grid.RowCnt %>_xwfb_fbsj" class="control-group xwfb_fbsj">
<input type="text" data-field="x_fbsj" name="x<%= xwfb_grid.RowIndex %>_fbsj" id="x<%= xwfb_grid.RowIndex %>_fbsj" placeholder="<%= xwfb.fbsj.PlaceHolder %>" value="<%= xwfb.fbsj.EditValue %>"<%= xwfb.fbsj.EditAttributes %>>
<% If Not xwfb.fbsj.ReadOnly And Not xwfb.fbsj.Disabled And xwfb.fbsj.EditAttrs.Item("readonly") = "" And xwfb.fbsj.EditAttrs.Item("disabled") = "" Then %>
<button id="cal_x<%= xwfb_grid.RowIndex %>_fbsj" name="cal_x<%= xwfb_grid.RowIndex %>_fbsj" class="btn" type="button"><img src="images/calendar.png" alt="<%= Language.Phrase("PickDate") %>" title="<%= Language.Phrase("PickDate") %>" style="border: 0;"></button><script type="text/javascript">
ew_CreateCalendar("fxwfbgrid", "x<%= xwfb_grid.RowIndex %>_fbsj", "%Y-%m-%d");
</script>
<% End If %>
</span>
<% End If %>
<% If xwfb.RowType = EW_ROWTYPE_VIEW Then ' View Record %>
<span<%= xwfb.fbsj.ViewAttributes %>>
<%= xwfb.fbsj.ListViewValue %>
</span>
<input type="hidden" data-field="x_fbsj" name="x<%= xwfb_grid.RowIndex %>_fbsj" id="x<%= xwfb_grid.RowIndex %>_fbsj" value="<%= Server.HTMLEncode(xwfb.fbsj.FormValue&"") %>">
<input type="hidden" data-field="x_fbsj" name="o<%= xwfb_grid.RowIndex %>_fbsj" id="o<%= xwfb_grid.RowIndex %>_fbsj" value="<%= Server.HTMLEncode(xwfb.fbsj.OldValue&"") %>">
<% End If %>
</td>
	<% End If %>
	<% If xwfb.ishome.Visible Then ' ishome %>
		<td<%= xwfb.ishome.CellAttributes %>>
<% If xwfb.RowType = EW_ROWTYPE_ADD Then ' Add Record %>
<span id="el<%= xwfb_grid.RowCnt %>_xwfb_ishome" class="control-group xwfb_ishome">
<div id="tp_x<%= xwfb_grid.RowIndex %>_ishome" class="<%= EW_ITEM_TEMPLATE_CLASSNAME %>"><input type="radio" name="x<%= xwfb_grid.RowIndex %>_ishome" id="x<%= xwfb_grid.RowIndex %>_ishome" value="{value}"<%= xwfb.ishome.EditAttributes %>></div>
<div id="dsl_x<%= xwfb_grid.RowIndex %>_ishome" data-repeatcolumn="5" class="ewItemList">
<%
emptywrk = True
arwrk = xwfb.ishome.EditValue
If IsArray(arwrk) Then
	rowswrk = UBound(arwrk, 2)	
	For rowcntwrk = 0 To rowswrk
		If xwfb.ishome.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_ishome" name="x<%= xwfb_grid.RowIndex %>_ishome" id="x<%= xwfb_grid.RowIndex %>_ishome_<%= rowcntwrk %>" value="<%= Server.HtmlEncode(arwrk(0, rowcntwrk)&"") %>"<%= selwrk %><%= xwfb.ishome.EditAttributes %>><%= arwrk(1, rowcntwrk) %></label>
<%= ew_RepeatColumnTable(rowswrk, rowcntwrk, 5, 2) %>
<%
	Next
End If
If emptywrk Then xwfb.ishome.OldValue = ""
%>
</div>
</span>
<input type="hidden" data-field="x_ishome" name="o<%= xwfb_grid.RowIndex %>_ishome" id="o<%= xwfb_grid.RowIndex %>_ishome" value="<%= Server.HTMLEncode(xwfb.ishome.OldValue&"") %>">
<% End If %>
<% If xwfb.RowType = EW_ROWTYPE_EDIT Then ' Edit Record %>
<span id="el<%= xwfb_grid.RowCnt %>_xwfb_ishome" class="control-group xwfb_ishome">
<div id="tp_x<%= xwfb_grid.RowIndex %>_ishome" class="<%= EW_ITEM_TEMPLATE_CLASSNAME %>"><input type="radio" name="x<%= xwfb_grid.RowIndex %>_ishome" id="x<%= xwfb_grid.RowIndex %>_ishome" value="{value}"<%= xwfb.ishome.EditAttributes %>></div>
<div id="dsl_x<%= xwfb_grid.RowIndex %>_ishome" data-repeatcolumn="5" class="ewItemList">
<%
emptywrk = True
arwrk = xwfb.ishome.EditValue
If IsArray(arwrk) Then
	rowswrk = UBound(arwrk, 2)	
	For rowcntwrk = 0 To rowswrk
		If xwfb.ishome.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_ishome" name="x<%= xwfb_grid.RowIndex %>_ishome" id="x<%= xwfb_grid.RowIndex %>_ishome_<%= rowcntwrk %>" value="<%= Server.HtmlEncode(arwrk(0, rowcntwrk)&"") %>"<%= selwrk %><%= xwfb.ishome.EditAttributes %>><%= arwrk(1, rowcntwrk) %></label>
<%= ew_RepeatColumnTable(rowswrk, rowcntwrk, 5, 2) %>
<%
	Next
End If
If emptywrk Then xwfb.ishome.OldValue = ""
%>
</div>
</span>
<% End If %>
<% If xwfb.RowType = EW_ROWTYPE_VIEW Then ' View Record %>
<span<%= xwfb.ishome.ViewAttributes %>>
<%= xwfb.ishome.ListViewValue %>
</span>
<input type="hidden" data-field="x_ishome" name="x<%= xwfb_grid.RowIndex %>_ishome" id="x<%= xwfb_grid.RowIndex %>_ishome" value="<%= Server.HTMLEncode(xwfb.ishome.FormValue&"") %>">
<input type="hidden" data-field="x_ishome" name="o<%= xwfb_grid.RowIndex %>_ishome" id="o<%= xwfb_grid.RowIndex %>_ishome" value="<%= Server.HTMLEncode(xwfb.ishome.OldValue&"") %>">
<% End If %>
</td>
	<% End If %>
	<% If xwfb.px.Visible Then ' px %>
		<td<%= xwfb.px.CellAttributes %>>
<% If xwfb.RowType = EW_ROWTYPE_ADD Then ' Add Record %>
<span id="el<%= xwfb_grid.RowCnt %>_xwfb_px" class="control-group xwfb_px">
<input type="text" data-field="x_px" name="x<%= xwfb_grid.RowIndex %>_px" id="x<%= xwfb_grid.RowIndex %>_px" size="30" placeholder="<%= xwfb.px.PlaceHolder %>" value="<%= xwfb.px.EditValue %>"<%= xwfb.px.EditAttributes %>>
</span>
<input type="hidden" data-field="x_px" name="o<%= xwfb_grid.RowIndex %>_px" id="o<%= xwfb_grid.RowIndex %>_px" value="<%= Server.HTMLEncode(xwfb.px.OldValue&"") %>">
<% End If %>
<% If xwfb.RowType = EW_ROWTYPE_EDIT Then ' Edit Record %>
<span id="el<%= xwfb_grid.RowCnt %>_xwfb_px" class="control-group xwfb_px">
<input type="text" data-field="x_px" name="x<%= xwfb_grid.RowIndex %>_px" id="x<%= xwfb_grid.RowIndex %>_px" size="30" placeholder="<%= xwfb.px.PlaceHolder %>" value="<%= xwfb.px.EditValue %>"<%= xwfb.px.EditAttributes %>>
</span>
<% End If %>
<% If xwfb.RowType = EW_ROWTYPE_VIEW Then ' View Record %>
<span<%= xwfb.px.ViewAttributes %>>
<%= xwfb.px.ListViewValue %>
</span>
<input type="hidden" data-field="x_px" name="x<%= xwfb_grid.RowIndex %>_px" id="x<%= xwfb_grid.RowIndex %>_px" value="<%= Server.HTMLEncode(xwfb.px.FormValue&"") %>">
<input type="hidden" data-field="x_px" name="o<%= xwfb_grid.RowIndex %>_px" id="o<%= xwfb_grid.RowIndex %>_px" value="<%= Server.HTMLEncode(xwfb.px.OldValue&"") %>">
<% End If %>
</td>
	<% End If %>
	<% If xwfb.newkey.Visible Then ' newkey %>
		<td<%= xwfb.newkey.CellAttributes %>>
<% If xwfb.RowType = EW_ROWTYPE_ADD Then ' Add Record %>
<span id="el<%= xwfb_grid.RowCnt %>_xwfb_newkey" class="control-group xwfb_newkey">
<input type="text" data-field="x_newkey" name="x<%= xwfb_grid.RowIndex %>_newkey" id="x<%= xwfb_grid.RowIndex %>_newkey" size="30" maxlength="255" placeholder="<%= xwfb.newkey.PlaceHolder %>" value="<%= xwfb.newkey.EditValue %>"<%= xwfb.newkey.EditAttributes %>>
</span>
<input type="hidden" data-field="x_newkey" name="o<%= xwfb_grid.RowIndex %>_newkey" id="o<%= xwfb_grid.RowIndex %>_newkey" value="<%= Server.HTMLEncode(xwfb.newkey.OldValue&"") %>">
<% End If %>
<% If xwfb.RowType = EW_ROWTYPE_EDIT Then ' Edit Record %>
<span id="el<%= xwfb_grid.RowCnt %>_xwfb_newkey" class="control-group xwfb_newkey">
<input type="text" data-field="x_newkey" name="x<%= xwfb_grid.RowIndex %>_newkey" id="x<%= xwfb_grid.RowIndex %>_newkey" size="30" maxlength="255" placeholder="<%= xwfb.newkey.PlaceHolder %>" value="<%= xwfb.newkey.EditValue %>"<%= xwfb.newkey.EditAttributes %>>
</span>
<% End If %>
<% If xwfb.RowType = EW_ROWTYPE_VIEW Then ' View Record %>
<span<%= xwfb.newkey.ViewAttributes %>>
<%= xwfb.newkey.ListViewValue %>
</span>
<input type="hidden" data-field="x_newkey" name="x<%= xwfb_grid.RowIndex %>_newkey" id="x<%= xwfb_grid.RowIndex %>_newkey" value="<%= Server.HTMLEncode(xwfb.newkey.FormValue&"") %>">
<input type="hidden" data-field="x_newkey" name="o<%= xwfb_grid.RowIndex %>_newkey" id="o<%= xwfb_grid.RowIndex %>_newkey" value="<%= Server.HTMLEncode(xwfb.newkey.OldValue&"") %>">
<% End If %>
</td>
	<% End If %>
	<% If xwfb.tags.Visible Then ' tags %>
		<td<%= xwfb.tags.CellAttributes %>>
<% If xwfb.RowType = EW_ROWTYPE_ADD Then ' Add Record %>
<span id="el<%= xwfb_grid.RowCnt %>_xwfb_tags" class="control-group xwfb_tags">
<input type="text" data-field="x_tags" name="x<%= xwfb_grid.RowIndex %>_tags" id="x<%= xwfb_grid.RowIndex %>_tags" size="30" maxlength="255" placeholder="<%= xwfb.tags.PlaceHolder %>" value="<%= xwfb.tags.EditValue %>"<%= xwfb.tags.EditAttributes %>>
</span>
<input type="hidden" data-field="x_tags" name="o<%= xwfb_grid.RowIndex %>_tags" id="o<%= xwfb_grid.RowIndex %>_tags" value="<%= Server.HTMLEncode(xwfb.tags.OldValue&"") %>">
<% End If %>
<% If xwfb.RowType = EW_ROWTYPE_EDIT Then ' Edit Record %>
<span id="el<%= xwfb_grid.RowCnt %>_xwfb_tags" class="control-group xwfb_tags">
<input type="text" data-field="x_tags" name="x<%= xwfb_grid.RowIndex %>_tags" id="x<%= xwfb_grid.RowIndex %>_tags" size="30" maxlength="255" placeholder="<%= xwfb.tags.PlaceHolder %>" value="<%= xwfb.tags.EditValue %>"<%= xwfb.tags.EditAttributes %>>
</span>
<% End If %>
<% If xwfb.RowType = EW_ROWTYPE_VIEW Then ' View Record %>
<span<%= xwfb.tags.ViewAttributes %>>
<%= xwfb.tags.ListViewValue %>
</span>
<input type="hidden" data-field="x_tags" name="x<%= xwfb_grid.RowIndex %>_tags" id="x<%= xwfb_grid.RowIndex %>_tags" value="<%= Server.HTMLEncode(xwfb.tags.FormValue&"") %>">
<input type="hidden" data-field="x_tags" name="o<%= xwfb_grid.RowIndex %>_tags" id="o<%= xwfb_grid.RowIndex %>_tags" value="<%= Server.HTMLEncode(xwfb.tags.OldValue&"") %>">
<% End If %>
</td>
	<% End If %>
<%

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

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

		' Render row
		Call xwfb_grid.RenderRow()

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

' Render list options (body, left)
xwfb_grid.ListOptions.Render "body", "left", xwfb_grid.RowIndex, "", "", ""
%>
	<% If xwfb.id.Visible Then ' id %>
		<td>
<% If xwfb.CurrentAction <> "F" Then %>
<% Else %>
<span id="el$rowindex$_xwfb_id" class="control-group xwfb_id">
<span<%= xwfb.id.ViewAttributes %>>
<%= xwfb.id.ViewValue %>
</span>
</span>
<input type="hidden" data-field="x_id" name="x<%= xwfb_grid.RowIndex %>_id" id="x<%= xwfb_grid.RowIndex %>_id" value="<%= Server.HTMLEncode(xwfb.id.FormValue&"") %>">
<% End If %>
<input type="hidden" data-field="x_id" name="o<%= xwfb_grid.RowIndex %>_id" id="o<%= xwfb_grid.RowIndex %>_id" value="<%= Server.HTMLEncode(xwfb.id.OldValue&"") %>">
</td>
	<% End If %>
	<% If xwfb.bh.Visible Then ' bh %>
		<td>
<% If xwfb.CurrentAction <> "F" Then %>
<% If xwfb.bh.SessionValue <> "" Then %>
<span<%= xwfb.bh.ViewAttributes %>>
<%= xwfb.bh.ListViewValue %>
</span>
<input type="hidden" id="x<%= xwfb_grid.RowIndex %>_bh" name="x<%= xwfb_grid.RowIndex %>_bh" value="<%= ew_HtmlEncode(xwfb.bh.CurrentValue) %>">
<% Else %>
<% xwfb.bh.EditAttrs.UpdateAttribute "onchange", "ew_UpdateOpt.call(this, ['x" & xwfb_grid.RowIndex & "_lmid']);" %>
<select data-field="x_bh" id="x<%= xwfb_grid.RowIndex %>_bh" name="x<%= xwfb_grid.RowIndex %>_bh"<%= xwfb.bh.EditAttributes %>>
<%
emptywrk = True
If IsArray(xwfb.bh.EditValue) Then
	arwrk = xwfb.bh.EditValue
	For rowcntwrk = 0 To UBound(arwrk, 2)
		If arwrk(0, rowcntwrk)&"" = xwfb.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 xwfb.bh.OldValue = ""
%>
</select>
<script type="text/javascript">
fxwfbgrid.Lists["x_bh"].Options = <%= ew_IIf(IsArray(xwfb.bh.EditValue), ew_ArrayToJson(xwfb.bh.EditValue, 1), "[]") %>;
</script>
<% End If %>
<% Else %>
<span<%= xwfb.bh.ViewAttributes %>>
<%= xwfb.bh.ViewValue %>
</span>
<input type="hidden" data-field="x_bh" name="x<%= xwfb_grid.RowIndex %>_bh" id="x<%= xwfb_grid.RowIndex %>_bh" value="<%= Server.HTMLEncode(xwfb.bh.FormValue&"") %>">
<% End If %>
<input type="hidden" data-field="x_bh" name="o<%= xwfb_grid.RowIndex %>_bh" id="o<%= xwfb_grid.RowIndex %>_bh" value="<%= Server.HTMLEncode(xwfb.bh.OldValue&"") %>">
</td>
	<% End If %>
	<% If xwfb.lmid.Visible Then ' lmid %>
		<td>
<% If xwfb.CurrentAction <> "F" Then %>
<% If xwfb.lmid.SessionValue <> "" Then %>
<span<%= xwfb.lmid.ViewAttributes %>>
<%= xwfb.lmid.ListViewValue %>
</span>
<input type="hidden" id="x<%= xwfb_grid.RowIndex %>_lmid" name="x<%= xwfb_grid.RowIndex %>_lmid" value="<%= ew_HtmlEncode(xwfb.lmid.CurrentValue) %>">
<% Else %>
<select data-field="x_lmid" id="x<%= xwfb_grid.RowIndex %>_lmid" name="x<%= xwfb_grid.RowIndex %>_lmid"<%= xwfb.lmid.EditAttributes %>>
<%
emptywrk = True
If IsArray(xwfb.lmid.EditValue) Then
	arwrk = xwfb.lmid.EditValue
	For rowcntwrk = 0 To UBound(arwrk, 2)
		If arwrk(0, rowcntwrk)&"" = xwfb.lmid.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 xwfb.lmid.OldValue = ""
%>
</select>
<script type="text/javascript">
fxwfbgrid.Lists["x_lmid"].Options = <%= ew_IIf(IsArray(xwfb.lmid.EditValue), ew_ArrayToJson(xwfb.lmid.EditValue, 1), "[]") %>;
</script>
<% End If %>
<% Else %>
<span<%= xwfb.lmid.ViewAttributes %>>
<%= xwfb.lmid.ViewValue %>
</span>
<input type="hidden" data-field="x_lmid" name="x<%= xwfb_grid.RowIndex %>_lmid" id="x<%= xwfb_grid.RowIndex %>_lmid" value="<%= Server.HTMLEncode(xwfb.lmid.FormValue&"") %>">
<% End If %>
<input type="hidden" data-field="x_lmid" name="o<%= xwfb_grid.RowIndex %>_lmid" id="o<%= xwfb_grid.RowIndex %>_lmid" value="<%= Server.HTMLEncode(xwfb.lmid.OldValue&"") %>">
</td>
	<% End If %>
	<% If xwfb.xwbt.Visible Then ' xwbt %>
		<td>
<% If xwfb.CurrentAction <> "F" Then %>
<span id="el$rowindex$_xwfb_xwbt" class="control-group xwfb_xwbt">
<input type="text" data-field="x_xwbt" name="x<%= xwfb_grid.RowIndex %>_xwbt" id="x<%= xwfb_grid.RowIndex %>_xwbt" size="30" maxlength="50" placeholder="<%= xwfb.xwbt.PlaceHolder %>" value="<%= xwfb.xwbt.EditValue %>"<%= xwfb.xwbt.EditAttributes %>>
</span>
<% Else %>
<span id="el$rowindex$_xwfb_xwbt" class="control-group xwfb_xwbt">
<span<%= xwfb.xwbt.ViewAttributes %>>
<%= xwfb.xwbt.ViewValue %>
</span>
</span>
<input type="hidden" data-field="x_xwbt" name="x<%= xwfb_grid.RowIndex %>_xwbt" id="x<%= xwfb_grid.RowIndex %>_xwbt" value="<%= Server.HTMLEncode(xwfb.xwbt.FormValue&"") %>">
<% End If %>
<input type="hidden" data-field="x_xwbt" name="o<%= xwfb_grid.RowIndex %>_xwbt" id="o<%= xwfb_grid.RowIndex %>_xwbt" value="<%= Server.HTMLEncode(xwfb.xwbt.OldValue&"") %>">
</td>
	<% End If %>
	<% If xwfb.fbsj.Visible Then ' fbsj %>
		<td>
<% If xwfb.CurrentAction <> "F" Then %>
<span id="el$rowindex$_xwfb_fbsj" class="control-group xwfb_fbsj">
<input type="text" data-field="x_fbsj" name="x<%= xwfb_grid.RowIndex %>_fbsj" id="x<%= xwfb_grid.RowIndex %>_fbsj" placeholder="<%= xwfb.fbsj.PlaceHolder %>" value="<%= xwfb.fbsj.EditValue %>"<%= xwfb.fbsj.EditAttributes %>>
<% If Not xwfb.fbsj.ReadOnly And Not xwfb.fbsj.Disabled And xwfb.fbsj.EditAttrs.Item("readonly") = "" And xwfb.fbsj.EditAttrs.Item("disabled") = "" Then %>
<button id="cal_x<%= xwfb_grid.RowIndex %>_fbsj" name="cal_x<%= xwfb_grid.RowIndex %>_fbsj" class="btn" type="button"><img src="images/calendar.png" alt="<%= Language.Phrase("PickDate") %>" title="<%= Language.Phrase("PickDate") %>" style="border: 0;"></button><script type="text/javascript">
ew_CreateCalendar("fxwfbgrid", "x<%= xwfb_grid.RowIndex %>_fbsj", "%Y-%m-%d");
</script>
<% End If %>
</span>
<% Else %>
<span id="el$rowindex$_xwfb_fbsj" class="control-group xwfb_fbsj">
<span<%= xwfb.fbsj.ViewAttributes %>>
<%= xwfb.fbsj.ViewValue %>
</span>
</span>
<input type="hidden" data-field="x_fbsj" name="x<%= xwfb_grid.RowIndex %>_fbsj" id="x<%= xwfb_grid.RowIndex %>_fbsj" value="<%= Server.HTMLEncode(xwfb.fbsj.FormValue&"") %>">
<% End If %>
<input type="hidden" data-field="x_fbsj" name="o<%= xwfb_grid.RowIndex %>_fbsj" id="o<%= xwfb_grid.RowIndex %>_fbsj" value="<%= Server.HTMLEncode(xwfb.fbsj.OldValue&"") %>">
</td>
	<% End If %>
	<% If xwfb.ishome.Visible Then ' ishome %>
		<td>
<% If xwfb.CurrentAction <> "F" Then %>
<span id="el$rowindex$_xwfb_ishome" class="control-group xwfb_ishome">
<div id="tp_x<%= xwfb_grid.RowIndex %>_ishome" class="<%= EW_ITEM_TEMPLATE_CLASSNAME %>"><input type="radio" name="x<%= xwfb_grid.RowIndex %>_ishome" id="x<%= xwfb_grid.RowIndex %>_ishome" value="{value}"<%= xwfb.ishome.EditAttributes %>></div>
<div id="dsl_x<%= xwfb_grid.RowIndex %>_ishome" data-repeatcolumn="5" class="ewItemList">
<%
emptywrk = True
arwrk = xwfb.ishome.EditValue
If IsArray(arwrk) Then
	rowswrk = UBound(arwrk, 2)	
	For rowcntwrk = 0 To rowswrk
		If xwfb.ishome.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_ishome" name="x<%= xwfb_grid.RowIndex %>_ishome" id="x<%= xwfb_grid.RowIndex %>_ishome_<%= rowcntwrk %>" value="<%= Server.HtmlEncode(arwrk(0, rowcntwrk)&"") %>"<%= selwrk %><%= xwfb.ishome.EditAttributes %>><%= arwrk(1, rowcntwrk) %></label>
<%= ew_RepeatColumnTable(rowswrk, rowcntwrk, 5, 2) %>
<%
	Next
End If
If emptywrk Then xwfb.ishome.OldValue = ""
%>
</div>
</span>
<% Else %>
<span id="el$rowindex$_xwfb_ishome" class="control-group xwfb_ishome">
<span<%= xwfb.ishome.ViewAttributes %>>
<%= xwfb.ishome.ViewValue %>
</span>
</span>
<input type="hidden" data-field="x_ishome" name="x<%= xwfb_grid.RowIndex %>_ishome" id="x<%= xwfb_grid.RowIndex %>_ishome" value="<%= Server.HTMLEncode(xwfb.ishome.FormValue&"") %>">
<% End If %>
<input type="hidden" data-field="x_ishome" name="o<%= xwfb_grid.RowIndex %>_ishome" id="o<%= xwfb_grid.RowIndex %>_ishome" value="<%= Server.HTMLEncode(xwfb.ishome.OldValue&"") %>">
</td>
	<% End If %>
	<% If xwfb.px.Visible Then ' px %>
		<td>
<% If xwfb.CurrentAction <> "F" Then %>
<span id="el$rowindex$_xwfb_px" class="control-group xwfb_px">
<input type="text" data-field="x_px" name="x<%= xwfb_grid.RowIndex %>_px" id="x<%= xwfb_grid.RowIndex %>_px" size="30" placeholder="<%= xwfb.px.PlaceHolder %>" value="<%= xwfb.px.EditValue %>"<%= xwfb.px.EditAttributes %>>
</span>
<% Else %>
<span id="el$rowindex$_xwfb_px" class="control-group xwfb_px">
<span<%= xwfb.px.ViewAttributes %>>
<%= xwfb.px.ViewValue %>
</span>
</span>
<input type="hidden" data-field="x_px" name="x<%= xwfb_grid.RowIndex %>_px" id="x<%= xwfb_grid.RowIndex %>_px" value="<%= Server.HTMLEncode(xwfb.px.FormValue&"") %>">
<% End If %>
<input type="hidden" data-field="x_px" name="o<%= xwfb_grid.RowIndex %>_px" id="o<%= xwfb_grid.RowIndex %>_px" value="<%= Server.HTMLEncode(xwfb.px.OldValue&"") %>">
</td>
	<% End If %>
	<% If xwfb.newkey.Visible Then ' newkey %>
		<td>
<% If xwfb.CurrentAction <> "F" Then %>
<span id="el$rowindex$_xwfb_newkey" class="control-group xwfb_newkey">
<input type="text" data-field="x_newkey" name="x<%= xwfb_grid.RowIndex %>_newkey" id="x<%= xwfb_grid.RowIndex %>_newkey" size="30" maxlength="255" placeholder="<%= xwfb.newkey.PlaceHolder %>" value="<%= xwfb.newkey.EditValue %>"<%= xwfb.newkey.EditAttributes %>>
</span>
<% Else %>
<span id="el$rowindex$_xwfb_newkey" class="control-group xwfb_newkey">
<span<%= xwfb.newkey.ViewAttributes %>>
<%= xwfb.newkey.ViewValue %>
</span>
</span>
<input type="hidden" data-field="x_newkey" name="x<%= xwfb_grid.RowIndex %>_newkey" id="x<%= xwfb_grid.RowIndex %>_newkey" value="<%= Server.HTMLEncode(xwfb.newkey.FormValue&"") %>">
<% End If %>
<input type="hidden" data-field="x_newkey" name="o<%= xwfb_grid.RowIndex %>_newkey" id="o<%= xwfb_grid.RowIndex %>_newkey" value="<%= Server.HTMLEncode(xwfb.newkey.OldValue&"") %>">
</td>
	<% End If %>
	<% If xwfb.tags.Visible Then ' tags %>
		<td>
<% If xwfb.CurrentAction <> "F" Then %>
<span id="el$rowindex$_xwfb_tags" class="control-group xwfb_tags">
<input type="text" data-field="x_tags" name="x<%= xwfb_grid.RowIndex %>_tags" id="x<%= xwfb_grid.RowIndex %>_tags" size="30" maxlength="255" placeholder="<%= xwfb.tags.PlaceHolder %>" value="<%= xwfb.tags.EditValue %>"<%= xwfb.tags.EditAttributes %>>
</span>
<% Else %>
<span id="el$rowindex$_xwfb_tags" class="control-group xwfb_tags">
<span<%= xwfb.tags.ViewAttributes %>>
<%= xwfb.tags.ViewValue %>
</span>
</span>
<input type="hidden" data-field="x_tags" name="x<%= xwfb_grid.RowIndex %>_tags" id="x<%= xwfb_grid.RowIndex %>_tags" value="<%= Server.HTMLEncode(xwfb.tags.FormValue&"") %>">
<% End If %>
<input type="hidden" data-field="x_tags" name="o<%= xwfb_grid.RowIndex %>_tags" id="o<%= xwfb_grid.RowIndex %>_tags" value="<%= Server.HTMLEncode(xwfb.tags.OldValue&"") %>">
</td>
	<% End If %>
<%

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

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

' Drop page object
Set xwfb_grid = Nothing
%>
