Question about the select condition query of datatable

Source: Internet
Author: User

Front-end code:

<% @ Control Language = "C #" autoeventwireup = "true" codefile = "myworkflowsearch. ascx. cs"
Inherits = "othinker. h3.portal. Controls. myworkflowsearch" %>
<% @ Register Assembly = "othinker. h3.worksheet" namespace = "othinker. h3.worksheet" tagprefix = "sheetcontrols" %>
<Link href = "<% = This. portalcssroot %>/mainui.css" rel = "stylesheet" type = "text/CSS"/>
<Style type = "text/CSS">
Body
{
Padding: 0;
Margin: 0;
Font-size: 12px;
}
. Text
{
Width: 99%;
}
. Text Li
{
Float: left;
Padding-Right: 20px;
Margin-top: 10px;
List-style: none;
Width: 80px;
Text-align: center;
Margin-bottom: 5px;
}
. Topnav
{
Width: 100%;
Height: 25px;
Background-color: # eaf4fc;
Line-Height: 25px;
Padding-left: 13px;
Font-weight: bold;
Clear: both;
}
</Style>
<Div class = "tablewrap" style = "Min-Height: 360px;">
<Table class = "flow_info_menu" border = "0" cellspacing = "0" cellpadding = "0">
<Tr>
<TD>
Template type: & nbsp;
<Asp: textbox id = "txtworkflowpack" runat = "server" width = "91px"> </ASP: textbox> & nbsp;
Template Name: & nbsp;
<Asp: textbox id = "txtworkflowname" runat = "server" width = "91px"> </ASP: textbox> & nbsp;
<Asp: linkbutton id = "btnsearch" runat = "server" onclick = "btnsearch_click"> query </ASP: linkbutton>
</TD>
</Tr>
</Table>
<Div class = "text">
<Asp: repeater id = "repeaterworkflow" runat = "server" onitemdatabound = "repeaterworkflow_itemdatabound">
<Itemtemplate>
<Div class = "topnav">
<Asp: Label id = "lbltitle" runat = "server"> <% # eval ("workflowpackage") %> </ASP: Label> </div>
<Div class = "text">
<Asp: repeater id = "subrepeaterworkflow" onitemdatabound = "subrepeaterworkflow_itemdatabound"
Runat = "server">
<Itemtemplate>
<Li> <span>
<Asp: hyperlink id = "linkworkflow" runat = "server">
<Sheetcontrols: binaryimage id = "binimgicon" runat = "server"/>
<Asp: Image id = "imgicon" runat = "server"/>
</ASP: hyperlink>
</Span>
<Br/>
<Span>
<Asp: hyperlink id = "linkworkflow1" runat = "server"> </ASP: hyperlink>
</Span> </LI>
</Itemtemplate>
</ASP: repeater>
</Div>
</Itemtemplate>
</ASP: repeater>
</Div>
</Div>
<SCRIPT type = "text/JavaScript" Language = "JavaScript">
Function OpenWindow (Openurl ){
// Var x = (screen. Height-height)/2;
// Var y = (screen. Width-width)/2;
VaR theopenwindow;
Theopenwindow = Window. Open (Openurl );
Theopenwindow. Focus ();
}
</SCRIPT>

Background code:

Using system;
Using system. Data;
Using system. Collections. Generic;
Using system. LINQ;
Using system. Web;
Using system. Web. UI;
Using system. Web. UI. webcontrols;
Using system. Web. UI. htmlcontrols;
Using othinker. h3.worksheet;

Namespace othinker. h3.portal. Controls
{
/// <Summary>
/// Display all process templates that I can launch
/// </Summary>
Public partial class myworkflowsearch: portalcontrol
{
/// <Summary>
/// Permissions required to open the page
/// </Summary>
Public override string functioncode
{
Get
{
Return othinker. h3.acl. functiondef. workspace_myworkflow_code;
}
}

Protected void page_load (Object sender, eventargs E)
{
If (! Ispostback)
{
Btnsearch_click (sender, e );
}
}
// Query button events
Protected void btnsearch_click (Object sender, eventargs E)
{
// Obtain the process template with the launch permission of the current user
Datatable table = othinker. h3.query. queryworkflow (this. uservalidator. recursivememberofs2 );
// Obtain a view of the result set of the Process Template.
Dataview DV = table. defaultview;
// Obtain the template type to be displayed by filtering the search criteria
DV. rowfilter = "1 = 1 ";
If (! String.isnullorempty(this.txt workflowpack. Text ))
{
DV. rowfilter + = "and workflowpackage like '%" + this.txt workflowpack. Text + "% '";
}
If (! String.isnullorempty(this.txt workflowname. Text. Trim (). Trim ()))
{
DV. rowfilter + = "and workflowname like '%" + this.txt workflowname. Text. Trim (). Trim () + "% '";
}
// Bind the widget to display the image type
This. repeaterworkflow. datasource = DV. totable (true, "workflowpackage ");
This. repeaterworkflow. databind ();
}
// Bind a repeater row event
Protected void repeaterworkflow_itemdatabound (Object sender, repeateritemeventargs E)
{
// Obtain the foreground Control
Datarowview rowv = (datarowview) E. Item. dataitem;
Label lbltitle = E. Item. findcontrol ("lbltitle") as label;
Lbltitle. Text = rowv ["workflowpackage"] + String. empty;
Repeater subrepeaterworkflow = E. Item. findcontrol ("subrepeaterworkflow") as repeater;
// Obtain the process template with the launch permission of the current user
Datatable table = othinker. h3.query. queryworkflow (this. uservalidator. recursivememberofs2 );
// Adds conditional filtering to the view
Dataview DV = new dataview (table );
DV. rowfilter = "workflowpackage = '" + rowv ["workflowpackage"] + String. Empty + "'";
If (! String.isnullorempty(this.txt workflowname. Text. Trim (). Trim ()))
{
DV. rowfilter + = "and workflowname like '%" + this.txt workflowname. Text. Trim () + "% '";
}
// Bind the Process Template Display Control
Subrepeaterworkflow. datasource = DV. totable (true, new string [] {"workflowpackage", "workflowname", "defaultversion", "iconcontent"}); // obtain the data source to filter duplicate rows.
Subrepeaterworkflow. databind ();
}
// Bind a repeater row event
Protected void subrepeaterworkflow_itemdatabound (Object sender, repeateritemeventargs E)
{
Datarowview rowv = (datarowview) E. Item. dataitem; // field data of the current row
Hyperlink linkworkflow = E. Item. findcontrol ("linkworkflow") as hyperlink;
Hyperlink linkworkflow1 = E. Item. findcontrol ("linkworkflow1") as hyperlink;
Image imgicon = E. Item. findcontrol ("imgicon") as image;
Binaryimage binimgicon = E. Item. findcontrol ("binimgicon") as binaryimage; // H3 image control

String imageurl = portalpage. getportalimageroot (this. Page) + "/workflow.png"; // default icon path
String urlstr = string. empty;
String workflowpackage = rowv ["workflowpackage"] + String. Empty; // Process Template type name
String workflowname = rowv ["workflowname"] + String. Empty; // Process Template Name
String workflowversion = rowv ["defaultversion"] + String. Empty; // version
Byte [] iconcontent = rowv ["iconcontent"] As byte []; // icon file byte
// If an icon exists
If (iconcontent! = NULL)
{
Binimgicon. Binary = iconcontent; // obtain the image path after generating the image.
Binimgicon. Visible = true;
Imgicon. Visible = false;
}
Else
{
Imgicon. imageurl = imageurl;
Binimgicon. Visible = false;
Imgicon. Visible = true;
}
Urlstr + = "javascript: OpenWindow (encodeuri (\ 'startinstance. aspx? Workflowpackage = "+ workflowpackage +" & workflowname = "+ workflowname +" & workflowversion = "+ workflowversion +" & pageaction = close \'));";
// Link on the icon
Linkworkflow. navigateurl = urlstr;
// Text link under the icon
Linkworkflow1.navigateurl = urlstr;
Linkworkflow1.text = workflowname;
}
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.