I have written a custom lookup filter in CRM entity. When CRM language is english everything works fine. As soon as I change the language to Swedish, lookup filter do not show any results for initial characters.
What could be the problem?
fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>"
+ "<entity name='product'>"
+ "<attribute name='name' />"
+ "<attribute name='productid' />"
+ "<attribute name='category' />"
+ "<attribute name='externalid' />"
+ "<order attribute='productnumber' descending='false' />"
+ "<filter type='and'>"
+ "<condition attribute='category' operator='in'>"
+ strValue
+ "</condition>"
+ "<condition attribute='type' operator='eq' value='1' />"
+ "</filter>"
+ "</entity>"
+ "</fetch>";
var layoutXml = "<grid name='resultset' object='1' jump='productid' select='1' icon='1' preview='1'>"
+ "<row name='result' id='productid'>"
+ "<cell name='name' width='300' />"
+ "<cell name='category' width='150' />"
+ "<cell name='productid' width='150' />"
+ "</row>"
+ "</grid>";
Xrm.Page.getControl("product").addCustomView(viewId, "product", viewDisplayName, fetchXml, layoutXml, true);
I have an application that using MVC pattern, ZK 8 version and Tree component as a menu. The application itself using border layout and Tabbox as a dynamic container. The menu tree code is adding tab when it is clicked. I have successfuly do this, but in an inefficient manner. Is there an efficient alternatives or ways to refactor?
The codes are:
<zk>
<style src="css/style.css" />
<borderlayout>
<north>
<div height="120px"
style="background:#3461b2
url('images/banner.jpg')no-repeat;" />
</north>
<west title="Selamat Datang - ${sessionScope.userCredential.name}"
size="22%" autoscroll="true" splittable="true" collapsible="true"
vflex="max">
<tree id="menuTree">
<treechildren>
<treeitem label="Daily">
<treechildren>
<treeitem label="Report 1">
<attribute name="onClick">
<![CDATA[
Tab newTab;
if (mainTabbox.getTabs().hasFellow("Report 1")) {
newTab = (Tab) mainTabbox.getTabs().getFellow("Report 1");
mainTabbox.setSelectedTab(newTab);
} else {
newTab = new Tab("Report 1");
newTab.setId("Report 1");
newTab.setClosable(true);
newTab.setSelected(true);
Tabpanel tb = new Tabpanel();
Executions.createComponents("daily/report1.zul", tb, null);
mainTabbox.getTabs().appendChild(newTab);
mainTabbox.getTabpanels().appendChild(tb);
}
]]>
</attribute>
</treeitem>
<treeitem label="Logs">
<attribute name="onClick">
<![CDATA[
Tab newTab;
if (mainTabbox.getTabs().hasFellow("Logs")) {
newTab = (Tab) mainTabbox.getTabs().getFellow("Logs");
mainTabbox.setSelectedTab(newTab);
} else {
newTab = new Tab("Logs");
newTab.setId("Logs");
newTab.setClosable(true);
newTab.setSelected(true);
Tabpanel tb = new Tabpanel();
Executions.createComponents("Logs.zul", tb, null);
mainTabbox.getTabs().appendChild(newTab);
mainTabbox.getTabpanels().appendChild(tb);
}
]]>
</attribute>
</treeitem>
...
...
<center vflex="min" autoscroll="true">
<div height="100%">
<tabbox id="mainTabbox">
<tabs id="tabs">
<tab id="mainTab" label="Main" />
</tabs>
<tabpanels>
<tabpanel>
<include src="/charts/mainChart.zul" />
</tabpanel>
</tabpanels>
</tabbox>
</div>
</center>
....
I found the solution by using onSelect listener attribute:
<tree id="menuTree">
<attribute name="onSelect">
<![CDATA[
Treeitem item = self.getSelectedItem();
if (item != null) {
Tab newTab;
if (mainTabbox.getTabs().hasFellow(item.getLabel())) {
newTab = (Tab) mainTabbox.getTabs().getFellow(item.getLabel());
mainTabbox.setSelectedTab(newTab);
} else {
newTab = new Tab(item.getLabel());
newTab.setId(item.getLabel());
newTab.setClosable(true);
newTab.setSelected(true);
Tabpanel tb = new Tabpanel();
Executions.createComponents(item.getValue().toString(), tb, null);
mainTabbox.getTabs().appendChild(newTab);
mainTabbox.getTabpanels().appendChild(tb);
}
}
]]>
</attribute>
<treechildren>
<treeitem label="Daily">
<treechildren>
<treeitem label="Tab Label" value="somepage.zul" />
<treeitem label="Other Tab Label" value="otherpage.zul" />
....
reference from: http://forum.zkoss.org/question/3675/tree-onselect-eventlistener/
I have a RadGrid which on RowClick should send a specific value to the server. Due to the nature of the page all events are handled Server Side. My -Radgrid1- uses a default "select" all sqldatasource when first accessing the page and then, you can filter RadGrid1 items by clicking on another RadGridAnother. which also has a list of different categories.
What happens is :
1. Row is clicked
2. radgrid1_ItemCommand(...,...) is executed.
Code Below changed to actual after Edit :
protected void MenuKampionati_ItemClick(object sender, RadMenuEventArgs e)
{
Case = 2;
Arg1 = "%%";
Arg2 = e.Item.Value;
string query = "EXECUTE get_ndeshje_kot31 " + Case.ToString() + ", '" + Arg1 + "', '" + Arg2 + "', 0";
SqlDataSource MyDataSource = new SqlDataSource(ConfigurationManager.ConnectionStrings["basteConnectionString"].ConnectionString, query);
this.GridNdeshjet.DataSource = MyDataSource;
this.GridNdeshjet.DataBind();
}
3. Page "refreshes" and RadGrid1 has the Old values in it + the label has default text of test.
I have read all Telerik API regarding this matter, and tried previuos solutions in vain.
Is there something I am missing? or forgetting to do? Has anyone any idea why this might be happening?
Regarding AJAX, my manager has instructed me not to "AJAX" this page. Hope my english is good enough for this problem.
Edit : I got a PM about my query, i have already tested it in sqlserver management studio and it is fully functional. I am now adding aspx code of the div that contains this controls, outside there are labels, some aspbutton and nothing more not related to the contents of this div.
Second Edit, Previous Grids were changed to RadMenu. Codebehind is still the same, just associated with the new Menu.
<div>
<table>
<tr>
<td><asp:UpdatePanel ID="panelGetTeGjitha" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false" >
<ContentTemplate>
<telerik:RadMenu ID="MenuKategoria" runat="server" DataSourceID="GetKategoriaDataSource"
DataTextField="kategoria" DataValueField="vlera" Flow="Vertical"
DataFieldID="kategoria"
onitemclick="MenuKategoria_ItemClick">
</telerik:RadMenu>
<asp:SqlDataSource ID="GetKategoriaDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:basteConnectionString %>"
SelectCommand="Get_Kategorite" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:SessionParameter DefaultValue="0" Name="Country" SessionField="country"
Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
</ContentTemplate>
</asp:UpdatePanel></td>
<td><asp:UpdatePanel ID="panelGetKampionati" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false" >
<ContentTemplate>
<telerik:RadMenu ID="MenuKampionati" runat="server" DataSourceID="GetKampionatiDataSource"
DataTextField="kampionati" DataValueField="kampionati" Flow="Vertical"
DataFieldID="kategoria" onitemclick="MenuKampionati_ItemClick" >
</telerik:RadMenu>
<asp:SqlDataSource ID="GetKampionatiDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:basteConnectionString %>" SelectCommand="SELECT kampionati FROM ndeshje (NOLOCK)
WHERE ((data > getdate() and ndeshje_id_live IS NULL) OR (data < getdate() AND data_hapjes > getdate() AND ndeshje_id_live IS NOT NULL))
AND bllokuar = '0' AND live = 0
GROUP BY kampionati ORDER by kampionati"></asp:SqlDataSource>
<telerik:RadGrid ID="GridNdeshjet" runat="server" GridLines="None"
onneeddatasource="GridNdeshjet_NeedDataSource1">
</telerik:RadGrid>
</ContentTemplate>
</asp:UpdatePanel></td>
<td><asp:UpdatePanel ID="panelGetNdeshje" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false" >
<ContentTemplate>
<telerik:RadMenu ID="MenuNdeshjeLive" runat="server" DataSourceID="GetNdeshjeLiveDataSource"
DataTextField="Home" DataValueField="Home" Flow="Vertical"
DataFieldID="Home" onitemclick="MenuKampionati_ItemClick" >
</telerik:RadMenu>
<asp:SqlDataSource ID="GetNdeshjeLiveDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:basteConnectionString %>" SelectCommand="SELECT MAX(Home) AS Home, MAX(Away) AS Away FROM ndeshje (NOLOCK)
WHERE(Data < getdate() AND data_hapjes > getdate() AND ndeshje_id_live IS NOT null AND live = 1)
AND bllokuar = '0' GROUP BY Home, Away ORDER BY Home, Away"></asp:SqlDataSource>
</ContentTemplate>
</asp:UpdatePanel></td>
</tr>
</table>
Let me know if any concern.
<asp:UpdatePanel ID="panelGetKampionati" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<telerik:RadMenu ID="MenuKampionati" runat="server" DataTextField="Name" DataValueField="ID"
Flow="Vertical" DataFieldID="ID" OnItemClick="MenuKampionati_ItemClick">
</telerik:RadMenu>
<telerik:RadGrid ID="GridNdeshjet" runat="server" GridLines="None" OnNeedDataSource="GridNdeshjet_NeedDataSource1">
</telerik:RadGrid>
</ContentTemplate>
</asp:UpdatePanel>
..........
protected void MenuKampionati_ItemClick(object sender, RadMenuEventArgs e)
{
GridNdeshjet.Rebind();
}
protected void GridNdeshjet_NeedDataSource1(object sender, GridNeedDataSourceEventArgs e)
{
string strID = string.Empty; // just For Test
if (MenuKampionati.SelectedItem != null)
{
// Get Selected Records as per item selected in RadMenu
//Case = 2;
//Arg1 = "%%";
string Arg2 = MenuKampionati.SelectedItem.Value;
//string query = "EXECUTE get_ndeshje_kot31 " + Case.ToString() + ", '" + Arg1 + "', '" + Arg2 + "', 0";
//SqlDataSource MyDataSource = new SqlDataSource(ConfigurationManager.ConnectionStrings["basteConnection
strID = MenuKampionati.SelectedItem.Value; // just For Test
}
else
{
// Get All records From DB
}
// just For Test
dynamic data = new[] {
new { ID = 1, Name ="Name" + strID},
new { ID = 2, Name ="Name"+ strID},
new { ID = 3, Name ="Name"+ strID},
new { ID = 4, Name ="Name"+ strID},
new { ID = 5, Name ="Name"+ strID},
new { ID = 6, Name = "Name"+ strID}
};
GridNdeshjet.DataSource = data;
}
I am not able to retrieve records from Oracle based on multiple inputs.
Here is my code:
Search.asp
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>SearchMDFnode</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#99CCFF">
<p align="center"><font color="#9966CC" size="5" face="Georgia, Times New Roman, Times, serif"><strong>Records</strong></font></p>
<style>
A:link {text-decoration: none;color: blue;}
A:visited {text-decoration: none;}
A:hover {text-decoration:underline; color: red;}
</style>
<script>
function updateDate(fname){
var instDate = showModalDialog('upd_date.html','Select Date','dialogHeight:375px;dialogWidth:287px;status:no;resizable:no;help:no;');
if (instDate == -1 || instDate == null){
alert("You did not select any date.")
fname.focus()
} else {
fname.value = instDate
}
}
function findNull(frm,tname,optnull,optorder){
var nfname = optnull.value
var ofname = optorder.value
frm.action = "MDFnodeDisplayTable.asp?opt=" + tname + "&nfield=" + nfname + "&order=" + ofname
frm.submit()
}
</script>
<form name="SearchMDFnode" action="Display.asp?opt=MDFnode" method="post">
<table width="68%" border="1" align="center" cellpadding="3" cellspacing="2">
<table width="94%" border="1" align="center" cellpadding="3" cellspacing="2">
<tr>
<td width="19%">CCP_CODE</td>
<td width="22%"><strong>
<select name="CCP_CODE" id="select4" title="BLOCK_HOUSE">
<option></option>
<option>AM</option>
<option>AR</option>
<option>BD</option>
<option>BP</option>
<option>CG</option>
<option>CT</option>
<option>CY</option>
<option>ES</option>
<option>GL</option>
<option>HG</option>
<option>JE</option>
<option>JR</option>
<option>JW</option>
<option>KT</option>
<option>NT</option>
<option>OC</option>
<option>PL</option>
<option>QT</option>
<option>TB</option>
<option>TP</option>
<option>TS</option>
</select>
</strong></td>
<td width="19%">NODE_SITE_ID</td>
<td width="40%"><strong>
<input name="NODE_SITE_ID" type="text" id="NODE_SITE_ID" size="10" maxlength="10" title="NODE_SITE_ID(max 7 digits)">
</strong></td>
</tr>
<tr>
<td>STREET_NAME</td>
<td><strong>
<input name="STREET_NAME" type="text" id="STREET_NAME" size="30" maxlength="30" title="STREET_NAME(max 30 digits)">
</strong></td>
<td>BUILDING_NAME</td>
<td><strong>
<input name="BUILDING_NAME" type="text" id="BUILDING_NAME" size="25" maxlength="25" title="BUILDING_NAME(max 7 digits)">
</strong></td>
</tr>
<tr>
<td height="38">BLOCK_HOUSE</td>
<td><strong>
<select name="BLOCK_HOUSE" id="select3" title="BLOCK_HOUSE">
<option></option>
<option>BLOCK</option>
<option>HOUSE</option>
</select>
</strong></td>
<td>BLOCK_DESC_NO</td>
<td><strong>
<input name="BLOCK_DESC_NO" type="text" id="BLOCK_DESC_NO" size="6" maxlength="6" title="BLOCK_DESC_NO(max 6 digits)">
</strong></td>
</tr>
<tr>
<td>REMARK</td>
<td><strong>
<input name="REMARK" type="text" id="REMARK" size="50" maxlength="50" title="REMARK(max 50 char)">
</strong></td>
<td>EQ_RM</td>
<td><strong>
<input name="EQ_RM" type="text" id="EQ_RM" size="3" maxlength="3" title="EQ_RM(max 6 digits)">
</strong></td>
</tr>
<tr>
<td>TYPE</td>
<td><strong>
<select name="EQ_TY" id="select" title="EQ_TY">
<option>CE</option>
<option></option>
</select>
</strong></td>
<td>CE_TY</td>
<td><strong>
<input name="CE_TY" type="text" id="CE_TY" size="10" maxlength="10" title="CE_TY(max 6 digits)">
</strong></td>
</tr>
<tr>
<td height="32">STATUS</td>
<td><strong>
<select name="STATUS" id="select2" title="EQ_TY">
<option></option>
<option>-</option>
<option>Site Survey</option>
<option>Survey Done</option>
<option>Document Sent</option>
<option>Equipment Installed</option>
<option>Commissioned</option>
<option>Cancelled</option>
</select>
</strong></td>
<td>NO</td>
<td><strong>
<input name="NO" type="text" id="NO" size="3" maxlength="3" title="NO (max 7 digits)">
<input name="UNIT_DESC_NO" type="text" id="UNIT_DESC_NO" size="2" maxlength="2" title="UNIT_DESC_NO (max 1 digits)">
<input name="NO_ME_CCTS" type="text" id="NO_ME_CCTS" size="2" maxlength="2" title="NO_ME_CCTS (max 2 digits)">
<input name="Rack" type="text" id="Rack" size="2" maxlength="2" title="Rack (max 1 digits)">
<input name="INSTALL_BY" type="text" id="INSTALL_BY" size="2" maxlength="2" title="INSTALL_BY (max 2 digits)">
</strong></td>
</tr>
<td height="32"><font color="#000000" size="3" face="Georgia, Times New Roman, Times, serif">Order By</font></td>
<td colspan="5"><select name="oMDFnode">
<option value="STATUS">STATUS</option>
<option value="NO">NO</option>
<option value="CCP_CODE">CCP_CODE</option>
<option value="CCP_CODE">NODE_SITE_ID</option>
</select>
<select name="orMDFnode" id="orMDFnode">
<option value="NO">NO</option>
<option value="STATUS">STATUS</option>
<option value="CCP_CODE">CCP_CODE</option>
<option value="CCP_CODE">NODE_SITE_ID</option>
</select>
<select name="ordMDFnode" id="ordMDFnode">
<option value="CCP_CODE">NODE_SITE_ID</option>
<option value="CCP_CODE">NO</option>
<option value="CCP_CODE">STATUS</option>
<option value="CCP_CODE">CCP_CODE</option>
</select></td>
</tr>
</table>
<p align="center">
<input type="submit" name="Submit" value="Search">
<input type="reset" name="reset" value="Clear">
</p>
</form>
<form name="commNull" method="post">
<tr>
<td height="56" colspan="4"><div align="center">
</div></td>
</tr>
</form>
</body>
</html>
Display.asp
<% option explicit %>
<!-- METADATA TYPE = "typelib" File = "c:\Program Files\Common Files\System\ado\msado15.dll" -->
<%
dim strTitle
dim strF, fname, ropt, j, i, sno, ropt1
dim objRS, strQuery, strConn, strSort,strQuery1
dim strHref
dim nodesiteid
'dim eq_ty
'ropt1 = request("opt1")
ropt = request("opt")
'eq_ty = request("EQ_TY")
nodesiteid = request("NODE_SITE_ID")
strQuery1 = request("NODE_SITE_ID")
Set objRS = Server.CreateObject("ADODB.Recordset")
strConn = "Provider=MSDAORA.1;Password=hr;User ID=hr;Data Source=xe;Persist Security Info=True"
strSort = ""
strF = "CCP_CODE, NODE_SITE_ID, STREET_NAME, BLOCK_HOUSE, BLOCK_DESC_NO, UNIT_DESC_NO, BUILDING_NAME, EQ_RM, EQ_TY, CE_TY , Rack, INSTALL_BY, STATUS, NO, RFS_DATE, REMARK, NO_ME_CCTS, NO_ME_CCTS" 'these were fields in sql table as well as input name in form
fname= split(strF,",",-1,vbtextcompare) 'split the above string to individual field
if trim(strQuery1) ="" then
strQuery = "select rowid,CCP_CODE, NODE_SITE_ID, STREET_NAME, BLOCK_HOUSE, BLOCK_DESC_NO, UNIT_DESC_NO, BUILDING_NAME, EQ_RM, EQ_TY, CE_TY , Rack, INSTALL_BY, STATUS, NO, RFS_DATE, REMARK, NO_ME_CCTS from MDF_NODE where CCP_CODE = CCP_CODE"
else
strQuery = "select rowid,CCP_CODE, NODE_SITE_ID, STREET_NAME, BLOCK_HOUSE, BLOCK_DESC_NO, UNIT_DESC_NO, BUILDING_NAME, EQ_RM, EQ_TY, CE_TY , Rack, INSTALL_BY, STATUS, NO, RFS_DATE, REMARK, NO_ME_CCTS from MDF_NODE where CCP_CODE = CCP_CODE and NODE_SITE_ID="
strQuery = strQuery & "'" & strQuery1 & "'"
end if
strSort = " order by " & request("oMDFnode") & "," & request("orMDFnode") & "," & request("ordMDFnode")
strTitle = "Summary of Carrier Ethernet Node"
if trim(request("nfield"))= "" then
j=0
for i= 0 to ubound(fname)
if request(fname(i)) <> "" then 'process if user input value in field
if j=0 then
strQuery = strQuery & " and " & fname(i) & " like '" & request(fname(i)) & "' " '1st field shd start with where clause
j = j + 1
else
strQuery = strQuery & " and " & fname(i) & " like '" & request(fname(i)) & "' " 'rest shd start with and clause
j = j + 1
end if
end if
next
strQuery = strQuery & strSort
else
strQuery = strQuery & " where " & trim(request("nfield")) & " is null order by " & trim(request("order"))
end if
objRS.Open strQuery, strConn,adOpenStatic,adLockOptimistic,adCmdText 'open recordset query oracle database
if objRS.eof then
objRS.close
set objRS = nothing
response.write "<script>alert('No Rows Selected')</script>" 'if eof mean NO data return
response.write "<script>history.back()</script>"
else
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>SdhTermDisplayTable2</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#99CCFF"><div align="center">
<p align="left"><strong>
<p> </p>
<p>
</p>
</strong>
<table width=945 align="center">
<tr class="nonPrint" height=30>
<td width="646" nowrap style="vertical-align:middle;font:bolder 12pt verdana;" >
<strong> <font size="4" face="Georgia, Times New Roman, Times, serif"> </font><font size="4" face="Georgia, Times New Roman, Times, serif">
Records/font></strong></td>
</table>
<strong>
<%
if trim(request("nfield"))= "" then
j=0
for i= 0 to ubound(fname)
if request(fname(i)) <> "" then 'process if user input value in field
if j=0 then
strQuery = strQuery & " where " & fname(i) & " like '" & request(fname(i)) & "' " '1st field shd start with where clause
j = j + 1
else
strQuery = strQuery & " and " & fname(i) & " like '" & request(fname(i)) & "' " 'rest shd start with and clause
j = j + 1
end if
end if
next
strQuery = strQuery & strSort
else
strQuery = strQuery & " where " & trim(request("nfield")) & " is null order by " & trim(request("order"))
end if
if objRS.eof then
objRS.close
set objRS = nothing
response.write "<script>alert('No Rows Selected')</script>" 'if eof mean NO data return
response.write "<script>history.back()</script>"
else
call drawHeader(ropt)
objRS.movefirst
sno = sno + 1
do until objRS.eof
call drawB(fname)
sno = sno + 1
objRS.movenext
loop
objRS.close
set objRS = nothing
end if
sub drawHeader(ropt)
response.write "<table id='tbl' table border=1 bordercolor='black' bgcolor='LavenderBlush' cellpadding=1 cellspacing=0 align=center style='BORDER-COLLAPSE: collapse;'>"
select case ropt
case "MDFnode"
response.write "<tr height=20><td><b>SNo</b></td>"
response.write "<td style='font:bold 11pt;' width=50>Exch</b></td><td><b>Cabinet</b></td><td><b>Street Name</b></td><td><b>BLK/HSE</b></td><td><b>No</b></td><td><b>Unit</b></td><td><b>Building Name</b></td><td><b>Room</b></td><td><b>Type</b></td><td><b>Equipment Type</b></td><td><b>Rack</b></td><td><b>Inst By</b></td><td><b>Status</b></td><td><b>ID</b></td><td><b>RFS Date</b></td><td><b>Remark</b></td><td><b>No of ccts</b></td>"
end select
response.write"</tr>"
end sub
response.write"</table>"
sub drawbody(ropt)
response.write "<tr>"
select case ropt
case "MDFnode"
for i= 0 to 10
response.write "<td>" & i & "</td>"
next
end select
response.write"</tr>"
end sub
sub drawB(ofname)
response.write "<tr>"
for i = 0 to ubound(ofname)
if isnull(objRS(i)) then
response.write "<td> </td>"
else
if i = 0 then
strHref = "<a href='e_" & ropt & ".asp?tname=" & ropt & "&rowid=" & server.URLEncode(trim(objRS("rowid"))) & "'>" & sno & "</a>"
response.write "<td style='font:normal 12pt Arial;'>" & strHref & "</td>"
else
response.write "<td style='font:normal 12pt Arial;'>" & trim(objRS(i)) & "</td>"
end if
end if
next
response.write "</tr>"
end sub
end if
response.write"</table>"
%>
</strong></p> </div>
<div align="center">
<input type="button" value="Save as Excel" onClick="vbscript:xlsReport()">
</div>
</p>
</body>
</html>
<script language="VBScript">
dim r, c, colcnt,row
sub xlsReport()
window.status = "Export to Excel ... Please Wait ..."
dim rownow
colcnt = tbl.cells.length / tbl.rows.length
set xls = createobject("Excel.Application")
xls.visible = true
xls.workbooks.add
xls.worksheets.add
for c = 0 to colcnt - 1
xls.cells(3,c+1).value = tbl.rows(0).cells(c).innerText
next
row = 3
for r = 1 to tbl.rows.length -1
for c = 0 to colcnt - 1
xls.cells(row+r,c+1).value = tbl.rows(r).cells(c).innerText
next
next
xls.cells(1,1).value = txtRpt.innerText
set xls = nothing
window.status = "Done"
end sub
</script>
</div>
I am getting records based on CCP_Code and NODE_SITE_ID values.
Now I want to retrieve values only based on TYPE = 'CE' but I am not able to do this.
When I didn't select anything by default the TYPE value is 'CE'. Click submit and it gives me only type CE values.
When I give CCp_code with TYPE = empty then it should give me all the records based on CCP_Code.
When I select CCP_CODE and NODE_SITE_ID it should give me values based on both.
When I select CCP_CODE, NODE_SITE_ID and TYPE='CE' then it should give me values based on these values.
You need to Google "SQL injection" for a start.
strQuery = strQuery & "'" & strQuery1 & "'"
But as a start I'd log the contents of "strQuery" just before the objRS.Open
Once you can see the query text, it should be easy to say why rows were or were not returned.
I am working on extending an ASP.NET 2.0 application using an InterBase database. My experience is in PHP/MySQL, so my familiarity with ASP is currently in the 2-week range, and is pieced together from examining a co-worker's code, the first 90 pages of my ASP book, and Google. In the application, I have an SqlDataSource control connecting to my database and selecting the information I need. Then the results are copied into a DataView where I modify the data in one of the columns, and then I push that DataView to a GridView for output. The issue I'm having is that I cannot sort the GridView at this point. I followed instructions here: http://forums.asp.net/p/956540/1177923.aspx, but to no avail.
Here is the page code:
<form id="form1" runat="server">
<div>
<asp:SqlDataSource ID="Products" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString1 %>"
ProviderName="<%$ ConnectionStrings:ConnectionString1.ProviderName %>" OnLoad="ProductsDS_Load"
OnSelected="ProductsDS_Selected" DataSourceMode="DataSet">
</asp:SqlDataSource>
<br />
<asp:Label ID="testlabel" runat="server"></asp:Label>
<br />
<asp:Label ID="testlabel2" runat="server"></asp:Label>
<br /><br />
This table lists all 2000+ numbered projects which are at least partially in process.<br />
The Project number link leads to a more detailed view of that project.<br />
<br />
<asp:Label runat="server" ID="numrows"></asp:Label> results returned.
<br />
<asp:GridView ID="ProductsView" runat="server" EnableModelValidation="True"
AutoGenerateColumns="False" CellPadding="4" OnSorting="ProductsView_Sorting"
ForeColor="#333333" GridLines="None" AllowSorting="True">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:HyperLinkField HeaderText="Project" SortExpression="PROJECT"
DataTextField="PROJECT" Target="subweeklyreport" DataNavigateUrlFields="PROJECT"
DataNavigateUrlFormatString="Products.aspx?p={0}" />
<asp:BoundField Visible="false" DataField="PROJECTID" />
<asp:BoundField DataField="PART" HeaderText="Part #"
SortExpression="PART" />
<asp:BoundField DataField="DESCRIPTION" HeaderText="Description"
SortExpression="DESCRIPTION" />
<asp:BoundField DataField="ENGMGR" HeaderText="Eng. Mgr."
SortExpression="ENGMGR" />
</Columns>
<EditRowStyle BackColor="#7C6F57" />
<FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#E3EAEB" />
<SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
</asp:GridView>
</div>
</form>
And here is the code behind:
protected void ProductsDS_Load(object sender, EventArgs e)
{
string SQLQuery = Query would go here;
testlabel2.Text = SQLQuery;
Products.SelectCommand = SQLQuery;
Products.DataBind();
DataView dv = (DataView)Products.Select(new DataSourceSelectArguments());
foreach (DataRow dr in dv.Table.Rows)
{
string name = dr["ENGMGR"].ToString();
string[] explode = name.Split(' ');
string newname;
if (explode.Length == 3)
{
newname = explode[2] + ", " + explode[0];
}
else
{
newname = explode[1] + ", " + explode[0];
}
dr["ENGMGR"] = newname;
//testlabel.Text = dr["ENGMGR"].ToString();
}
Products.DataBind();
//ProductsView.DataSourceID = "Products";
ProductsView.DataSource = dv;
ProductsView.DataBind();
ProductsView.Enabled = true;
ProductsView.Visible = true;
}
protected void ProductsDS_Selected(object sender, SqlDataSourceStatusEventArgs e)
{
numrows.Text = e.AffectedRows.ToString();
}
protected void ProductsView_Sorting(object sender, GridViewSortEventArgs e)
{
DataTable dataTable = ProductsView.DataSource as DataTable;
if (dataTable != null)
{
DataView dataView = new DataView(dataTable);
dataView.Sort = e.SortExpression + " " + ConvertSortDirectionToSql(e.SortDirection);
ProductsView.DataSource = dataView;
ProductsView.DataBind();
}
}
private string ConvertSortDirectionToSql(SortDirection sortDirection)
{
string newSortDirection = String.Empty;
switch (sortDirection)
{
case SortDirection.Ascending:
newSortDirection = "ASC";
break;
case SortDirection.Descending:
newSortDirection = "DESC";
break;
}
return newSortDirection;
}
What I think is happening is that whenever the GridView does the postback for the sort, it causes the query to be executed again and overwrite the attempt to sort the existing data in the GridView, but I don't know enough about ASP right now to prevent this behavior. Any help would be much appreciated.
I ended up solving my own problem. I created a session variable to store the dataview between page loads, and checking to see if the dataview is stored before executing the query, and sorting it if it is, and just performing the regular query otherwise. Since I don't expect data to be introduced between the initial page view and the sort, I don't think using a stored copy of the data would be a major issue.