Solved

Dynamic Linkbutton callback to a method.

Posted on 2007-12-06
9
715 Views
Last Modified: 2009-12-16
I have an application that has a search page. This page will do it initial query based on parameters input by the user, then its second query based on a selection from the result set. I am having issues with the second part. When I create the result set and display it I am making the unque identifier a link button that will pass its unique ID back to a method that looks up its details and displays the result. The method never seems to be called.

The resultstable is predefined in the ASPX page.
The method being called works, I know this because I can link it to a button on the ASPX page.
private void PopulateResultsData()
        {
            LinkButton lnkbttn = null;
            TableRow trHolder = null;
            TableCell tdholder1 = null;
            TableCell tdholder2 = null;
            TableCell tdholder3 = null;
            TableCell tdholder4 = null;
            TableCell tdholder5 = null;
            DataTable resultset = new DataTable();
            Search srch = new Search();
            resultset = srch.RetrieveResults("test");
            foreach (DataRow oRow in resultset.Rows)
            {
                lnkbttn = new LinkButton();
                trHolder = new TableRow();
                tdholder1 = new TableCell();
                tdholder2 = new TableCell();
                tdholder3 = new TableCell();
                tdholder4 = new TableCell();
                tdholder5 = new TableCell();
                lnkbttn.ID = oRow["CallNumber"];
                lnkbttn.Text = oRow["CallNumber"];
                lnkbttn.Click += new EventHandler(LnkClick_CallInformation);
                tdholder1.Controls.Add(lnkbttn);
                //tdholder1.Text = oRow["CallNumber"].ToString();
                tdholder2.Text = oRow["Partner"].ToString();
                tdholder3.Text = oRow["SystemSN"].ToString();
                tdholder4.Text = oRow["Date"].ToString();
                tdholder5.Text = oRow["Summary"].ToString();
                trHolder.Controls.Add(tdholder1);
                trHolder.Controls.Add(tdholder2);
                trHolder.Controls.Add(tdholder3);
                trHolder.Controls.Add(tdholder4);
                trHolder.Controls.Add(tdholder5);
                ResultsTable.Controls.Add(trHolder);
            }
        }

Open in new window

0
Comment
Question by:docstar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 10

Expert Comment

by:digitalZo
ID: 20425732
Can you also post the code of how and where it's being called?
0
 

Author Comment

by:docstar
ID: 20426844
Here is the HTML:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Clientele_Search._Default" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Clientele Search V 2.0</title>
    <link href="Styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="MainForm" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
    <div>
    <asp:Table ID="MainTable" runat="server" CssClass="MainTable" CellPadding="0" CellSpacing="0">
        <asp:TableRow>
            <asp:TableCell ColumnSpan="2" CssClass="header">
                <!-- Start Header -->
                Header
                <!-- End Header -->
            </asp:TableCell>            
        </asp:TableRow>
        <asp:TableRow>            
            <asp:TableCell>
                <asp:UpdatePanel ID="ParamAjax" runat="server" UpdateMode="conditional" ChildrenAsTriggers="false">
                <ContentTemplate>
                <!-- Start Search Parameters -->                 
                <asp:Panel ID="Panel15" runat="server" CssClass="SectionLabel">Search </asp:Panel>
                <asp:Panel ID="Panel1" runat="server" CssClass="SearchLabel">
                <asp:Label ID="Keywords1Image" runat="server"></asp:Label>Keywords: </asp:Panel>
                <asp:Panel ID="Panel2" runat="server" CssClass="SearchInput"><asp:TextBox ID="Keywords1" runat="server" CssClass="inputextbox" /></asp:Panel>
                <asp:Panel ID="Panel3" runat="server" CssClass="SearchLabel">
                <asp:Label ID="Keywords2Image" runat="server"></asp:Label>Keywords: </asp:Panel>
                <asp:Panel ID="Panel4" runat="server" CssClass="SearchInput"><asp:TextBox ID="Keywords2" runat="server" CssClass="inputextbox" /></asp:Panel>
                <asp:Panel ID="Panel5" runat="server" CssClass="SearchLabel">
                <asp:Label ID="SDateImage" runat="server"></asp:Label>Start Date: </asp:Panel>
                <asp:Panel ID="Panel6" runat="server" CssClass="SearchInput"><asp:TextBox ID="SDate" runat="server" CssClass="inputextbox" /></asp:Panel>
                <asp:Panel ID="Panel7" runat="server" CssClass="SearchLabel">
                <asp:Label ID="EDateImage" runat="server"></asp:Label>End Date: </asp:Panel>
                <asp:Panel ID="Panel8" runat="server" CssClass="SearchInput"><asp:TextBox ID="EDate" runat="server" CssClass="inputextbox" /></asp:Panel>
                <asp:Panel ID="Panel9" runat="server" CssClass="SearchLabel">
                <asp:Label ID="SupportTechImage" runat="server"></asp:Label>Employee:</asp:Panel>
                <asp:Panel ID="Panel10" runat="server" CssClass="SearchInput"><asp:TextBox ID="SupportTech" runat="server" CssClass="inputextbox" /></asp:Panel>
                <asp:Panel ID="Panel11" runat="server" CssClass="SearchLabel">
                <asp:Label ID="FieldTechImage" runat="server"></asp:Label>Field Tech: </asp:Panel>
                <asp:Panel ID="Panel12" runat="server" CssClass="SearchInput"><asp:TextBox ID="FieldTech" runat="server" CssClass="inputextbox" /></asp:Panel>
                <asp:Panel ID="Panel13" runat="server" CssClass="SearchLabel">
                <asp:Label ID="PartnerImage" runat="server"></asp:Label>Partner: </asp:Panel>
                <asp:Panel ID="Panel14" runat="server" CssClass="SearchInput"><asp:TextBox ID="Partner" runat="server" CssClass="inputextbox" /></asp:Panel>
                <asp:Panel ID="Panel16" runat="server" CssClass="SearchLabel">
                <asp:Label ID="SSNImage" runat="server"></asp:Label>System SN: </asp:Panel>
                <asp:Panel ID="Panel17" runat="server" CssClass="SearchInput"><asp:TextBox ID="SSN" runat="server" CssClass="inputextbox" /></asp:Panel>
                <asp:Panel ID="Panel18" runat="server" CssClass="SearchLabel">
                <asp:Label ID="StatusImage" runat="server"></asp:Label>Status: </asp:Panel>
                <asp:Panel ID="Panel19" runat="server" CssClass="SearchInput">
                    <asp:DropDownList ID="DropDownList1" runat="server" Width="100px">
                        <asp:ListItem Selected="True" Value="" Text=""/>
                        <asp:ListItem Value="0" Text="Open"/>
                        <asp:ListItem Value="-1" Text="Closed"/>
                    </asp:DropDownList>
                </asp:Panel>
                <asp:Button ID="SearchButton" runat="server" Text="Search" OnClick="BtnClick_Search" />
                <asp:Button ID="Button1" runat="server" Text="Search" OnClick="LnkClick_CallInformation" />
                <!-- End Search Parameters   LnkClick_CallInformation  BtnClick_Search -->
                    </ContentTemplate>
                    </asp:UpdatePanel>
            </asp:TableCell>                        
            <asp:TableCell VerticalAlign="top">
                <asp:UpdatePanel ID="DataupdateAjax" runat="server">
                <ContentTemplate>
                <!-- Start Data table -->
                <asp:Panel ID="resultsLable" runat="server" CssClass="SectionLabel"> Results</asp:Panel>
                <asp:Table ID="ResultsTable" runat="server" CssClass="MainTable" CellPadding="0" CellSpacing="0">
                    <asp:TableRow>
                        <asp:TableCell CssClass="ResultsHeaders" Width="150px">Call Number</asp:TableCell>
                        <asp:TableCell CssClass="ResultsHeaders" Width="150px">Partner</asp:TableCell>
                        <asp:TableCell CssClass="ResultsHeaders" Width="150px">System SN</asp:TableCell>
                        <asp:TableCell CssClass="ResultsHeaders" Width="150px">Date</asp:TableCell>
                        <asp:TableCell CssClass="ResultsHeaders" Width="350px">Summary</asp:TableCell>
                    </asp:TableRow>
                </asp:Table>
                <!-- End Data table -->            
                </ContentTemplate>
                </asp:UpdatePanel>    
            </asp:TableCell>            
        </asp:TableRow>
    </asp:Table>  
    <asp:UpdatePanel ID="DataviewerAjax" runat="server" UpdateMode="conditional">
    <ContentTemplate> 
    <asp:Panel ID="Dataviewer" runat="server" CssClass="Dataviewer">
        <asp:Button ID="CloseDataViewer" runat="server" Text="Close" OnClick="BtnClick_CloseDataViewer" />
        <asp:Label ID="CallNotes" runat="server"></asp:Label>       
    </asp:Panel>
    </ContentTemplate>
    </asp:UpdatePanel>
    </div>
    </form>
</body>
</html>

Open in new window

0
 

Author Comment

by:docstar
ID: 20426857
Code Behind for Default.aspx:

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
 
namespace Clientele_Search
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (this.Page.IsPostBack == false)
            {
                InitPage();
            }
        }
 
        private void InitPage()
        {
            Dataviewer.Visible = false;
        }
 
        private void PopulateResultsData()
        {
            LinkButton lnkbttn = null;
            TableRow trHolder = null;
            TableCell tdholder1 = null;
            TableCell tdholder2 = null;
            TableCell tdholder3 = null;
            TableCell tdholder4 = null;
            TableCell tdholder5 = null;
            DataTable resultset = new DataTable();
            Search srch = new Search();
            resultset = srch.RetrieveResults("test");
            foreach (DataRow oRow in resultset.Rows)
            {
                lnkbttn = new LinkButton();
                trHolder = new TableRow();
                tdholder1 = new TableCell();
                tdholder2 = new TableCell();
                tdholder3 = new TableCell();
                tdholder4 = new TableCell();
                tdholder5 = new TableCell();
                lnkbttn.ID = oRow["CallNumber"].ToString();
                lnkbttn.Text = oRow["CallNumber"].ToString();
                lnkbttn.Click += new EventHandler(LnkClick_CallInformation);
                tdholder1.Controls.Add(lnkbttn);
                //tdholder1.Text = oRow["CallNumber"].ToString();
                tdholder2.Text = oRow["Partner"].ToString();
                tdholder3.Text = oRow["SystemSN"].ToString();
                tdholder4.Text = oRow["Date"].ToString();
                tdholder5.Text = oRow["Summary"].ToString();
                trHolder.Controls.Add(tdholder1);
                trHolder.Controls.Add(tdholder2);
                trHolder.Controls.Add(tdholder3);
                trHolder.Controls.Add(tdholder4);
                trHolder.Controls.Add(tdholder5);
                ResultsTable.Controls.Add(trHolder);
                ParamAjax.Update();
            }
        }
 
        private void PopulateCallInformationData(string callid)
        {
            Table tblHolder = new Table();
            TableRow trHolder = null;
            TableCell tdholder1 = null;
            TableCell tdholder2 = null;
            TableCell tdholder3 = null;
            Search srch = new Search();
            DataTable resultset = new DataTable();
            resultset = srch.RetrieveNotes(callid);
            tblHolder.CssClass = "MainTable";
            foreach (DataRow oRow in resultset.Rows)
            {
                trHolder = new TableRow();
                tdholder1 = new TableCell();
                tdholder1.Text = oRow["Summary"].ToString();
                tdholder1.ColumnSpan = 3;
                tdholder1.CssClass = "ResultsHeaders";
                trHolder.Controls.Add(tdholder1);
                tblHolder.Controls.Add(trHolder);
                trHolder = new TableRow();
                tdholder1 = new TableCell();
                tdholder2 = new TableCell();
                tdholder3 = new TableCell();
                tdholder1.Text = oRow["SupportTech"].ToString();
                tdholder2.Text = oRow["FieldTech"].ToString();
                tdholder3.Text = oRow["Date"].ToString();
                trHolder.Controls.Add(tdholder1);
                trHolder.Controls.Add(tdholder2);
                trHolder.Controls.Add(tdholder3);
                tblHolder.Controls.Add(trHolder);
                trHolder = new TableRow();
                tdholder1 = new TableCell();
                tdholder1.Text = oRow["Notes"].ToString();
                tdholder1.ColumnSpan = 3;
                trHolder.Controls.Add(tdholder1);
                tblHolder.Controls.Add(trHolder);
            }
            CallNotes.Controls.Add(tblHolder);
            DataviewerAjax.Update();
        }
 
 
        public void BtnClick_Search(object sender, EventArgs e)
        {
            ; PopulateResultsData();
        }
        public void BtnClick_CloseDataViewer(object sender, EventArgs e)
        {
            Dataviewer.Visible = false;
            CallNotes.Text = "";
        }
        public void LnkClick_CallInformation(object sender, EventArgs e)
        {
            Dataviewer.Visible = true;
            PopulateCallInformationData("test");
        }
 
    }
}

Open in new window

0
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
LVL 10

Expert Comment

by:digitalZo
ID: 20439550
Can you tell me what the semi colon in the btnclick_search is for - the one which is before the method being called? Or is it a typo?

  public void BtnClick_Search(object sender, EventArgs e)
        {
            ; PopulateResultsData();
        }

Secondly, I would suggest to use breakpoint for debugging, to see in which order the application is reading the data and whether or not it is reading the method being called.
0
 

Author Comment

by:docstar
ID: 20440843
The semi colon is a typo.

I have run this in a debug mode with break points on all my on click actions.
The problem I am having is that the links that are created by the BtnClick_Search method are not calling the LnkClick_CallInformation method.
0
 
LVL 10

Accepted Solution

by:
digitalZo earned 250 total points
ID: 20447469
I think the answer to your problem is:

Dynamic controls need to be recreated on postback for their event handlers to run.

===

Well the problem lies in the fact that these are dynamically defined, and not permanent web controls. When the page reposts, they are not recognized by the code because at that time, they dont exist, and therefore will not fire the event to execute the subroutine. How do we fix this problem? Easy: re-create them everytime we create the page, in the page_load subroutine.

http://authors.aspalliance.com/articles/dynamicbuttons.aspx

So the event should be called on Page_Load too:

hth.
protected void Page_Load(object sender, EventArgs e)
        {
            if (this.Page.IsPostBack == false)
            {
                InitPage();
            }
 
            PopulateResultsData()
        }

Open in new window

0
 

Author Comment

by:docstar
ID: 20449335
I tested that and it does work when I populate the data on every post back. The problem is that the populateresultsdata() does a query to get its results. the reasoning for using ajax is so my app looks like a thick app and for a preformance gain (partial page refresh). Running the query on every post back will be a preformance hit. Can I cache the data somehow so on post back it simply repopulates the data from what it had?
0
 
LVL 10

Assisted Solution

by:digitalZo
digitalZo earned 250 total points
ID: 20455124
Put it in !IsPostBack:

This will populate the data only once.


protected void Page_Load(object sender, EventArgs e)
        {
           if (!IsPostBack) 
             {
                InitPage();
                PopulateResultsData();
 
             }
          
            
        }

Open in new window

0
 

Author Comment

by:docstar
ID: 20461195
Eurika!!!!!
Ok I had to save the query results into the viewstate so I would not have to be run on every post back.
I have posted all of my codebehind for anyone else who wants to see it.
The key was to as stated above recreate the buttons on every postback.  The issue I had with that was that the query was run against the database on every postback. To resolve this I serialized the dataset and placed it into the viewstate. It may not be the best way but it works :).
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using System.Text.RegularExpressions;
 
 
namespace Clientele_Search
{
    public partial class _Default : System.Web.UI.Page
    {
        #region Properties        
        /// <summary>
        /// Serializes and Caches the results into the viewstate. This prevents a quary from having to be run on every postback.
        /// </summary>
        /// <value>The data returned from a query.</value>
        private DataSet SourceData
        {
            get { return (DataSet)this.ViewState["SourceData"]; }
            set { this.ViewState["SourceData"] = value; }
        }
        /// <summary>
        /// Serializes and Caches the SQL run prior to post back. 
        /// This allows the query to be evalutated to see it needs to be run against the database.
        /// </summary>
        /// <value>The SQL run on the prior postback.</value>
        private string SqlRan
        {
            get { return (string)this.ViewState["SqlRan"]; }
            set { this.ViewState["SqlRan"] = value; }
        }
        #endregion Properties
 
        #region Events
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (this.Page.IsPostBack == false) { InitPage(); }
            if (this.Page.IsPostBack == true)
            {
                string qry = BuildQryString_ResultsData();                
                PopulateResultsData(qry);
            }
        }
        /// <summary>
        /// Handles the on click event of the Search button.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        public void BtnClick_Search(object sender, EventArgs e)
        {
            Dataviewer.Visible = false;
        }
        /// <summary>
        /// Handles the on click event of the close button.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        public void BtnClick_CloseDataViewer(object sender, EventArgs e)
        {
            Dataviewer.Visible = false;
            CallNotes.Text = "";
        }
        /// <summary>
        /// Handles the click event of all dynamic controls on the ResultsData table.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        public void LnkClick_CallInformation(object sender, EventArgs e)
        {
            LinkButton lnkbtn = (LinkButton)(sender);
            Dataviewer.Visible = true;
            PopulateCallInformationData(lnkbtn.ID.ToString());
        }
        #endregion
 
        #region functions
        /// <summary>
        /// Initializes the page.
        /// </summary>
        private void InitPage()
        {
            Dataviewer.Visible = false;
        }
        /// <summary>
        /// Populates the call information data. This is a the div that shows all notes on a call.
        /// </summary>
        /// <param name="callid">The callid.</param>
        private void PopulateCallInformationData(string callid)
        {
            Table tblHolder = new Table();
            TableRow trHolder = null;
            TableCell tdholder1 = null;
            TableCell tdholder2 = null;
            TableCell tdholder3 = null;
            Search srch = new Search();
            SqlDataReader resultset = null;
            resultset = srch.RetrieveNotes(callid);
            tblHolder.CssClass = "MainTable";
            while (resultset.Read())
            {
                trHolder = new TableRow();
                tdholder1 = new TableCell();
                tdholder1.Text = Hightlight(resultset["Summary"].ToString());
                tdholder1.ColumnSpan = 3;
                tdholder1.CssClass = "ResultsHeaders";
                trHolder.Controls.Add(tdholder1);
                tblHolder.Controls.Add(trHolder);
                trHolder = new TableRow();
                tdholder1 = new TableCell();
                tdholder2 = new TableCell();
                tdholder3 = new TableCell();
                tdholder1.Text = resultset["SupportTech"].ToString();
                tdholder2.Text = resultset["FieldTech"].ToString();
                tdholder3.Text = resultset["AddDate"].ToString();
                //tdholder3.Text = callid;
                trHolder.Controls.Add(tdholder1);
                trHolder.Controls.Add(tdholder2);
                trHolder.Controls.Add(tdholder3);
                tblHolder.Controls.Add(trHolder);
                trHolder = new TableRow();
                tdholder1 = new TableCell();
                tdholder1.Text = Hightlight(resultset["Memo"].ToString());
                tdholder1.ColumnSpan = 3;
                trHolder.Controls.Add(tdholder1);
                tblHolder.Controls.Add(trHolder);
 
            }
            CallNotes.Controls.Add(tblHolder);
            num.Text = DataAjax.Triggers.Count.ToString();
        }
        /// <summary>
        /// Populates the results data. This is the main table a user will select from.
        /// </summary>
        /// <param name="qry">Quary to be run against the database.</param>
        private void PopulateResultsData(string qry)
        {
            LinkButton lnkbttn = null;
            TableRow trHolder = null;
            TableCell tdholder1 = null;
            TableCell tdholder2 = null;
            TableCell tdholder3 = null;
            TableCell tdholder4 = null;
            TableCell tdholder5 = null;
            DataSet resultset = null;
            /* Check to see if a query needs to be run 
             * If the SourceData is null a query needs to be run
             * If the Sql built does not match the sql ran on last postback a query needs to be run */
            if (this.SourceData == null | SqlRan != qry)
            {
                Search srch = new Search();
                resultset = srch.RetrieveResults(qry);
                this.SourceData = resultset;
                SqlRan = null;
            }
            else { resultset = this.SourceData; }
            if (SqlRan == null) { SqlRan = qry; }
            foreach (DataRow drRow in resultset.Tables[0].Rows)
            {
                lnkbttn = new LinkButton();
                trHolder = new TableRow();
                tdholder1 = new TableCell();
                tdholder2 = new TableCell();
                tdholder3 = new TableCell();
                tdholder4 = new TableCell();
                tdholder5 = new TableCell();
                lnkbttn.ID = drRow["Call_ID"].ToString();
                lnkbttn.Text = drRow["Call_Num"].ToString();
                lnkbttn.Click += this.LnkClick_CallInformation;
                tdholder1.Controls.Add(lnkbttn);
                tdholder2.Text = drRow["Partner"].ToString();
                tdholder3.Text = drRow["SSN"].ToString();
                tdholder4.Text = drRow["OpenDate"].ToString();
                tdholder5.Text = Hightlight(drRow["Summary"].ToString());
                trHolder.Controls.Add(tdholder1);
                trHolder.Controls.Add(tdholder2);
                trHolder.Controls.Add(tdholder3);
                trHolder.Controls.Add(tdholder4);
                trHolder.Controls.Add(tdholder5);
                ResultsTable.Controls.Add(trHolder);
 
            }            
            ResultsAjax.Update();
        }
        /// <summary>
        /// Builds the query string.
        /// </summary>
        /// <returns>A query string based on fields filled out.</returns>
        private string BuildQryString_ResultsData()
        {
            StringBuilder qrystr = new StringBuilder();
            qrystr.Append("Select top " + Max_Results.Text);
            qrystr.Append(" c.Call_ID, c.Call_Num, o.OrgName as Partner, IsNull(c.SerialNum, 'Not Provided') as SSN, ");
            qrystr.Append("c.OpenDate, IsNull(c.Summary, 'Summary is not filled out') as Summary from dbo.Call c ");
            qrystr.Append("left join dbo.Org o on c.Org_ID = o.Org_ID left join dbo.Event e on e.Call_ID = c.Call_ID left join dbo.Person p ");
            qrystr.Append("on p.Per_ID = e.SecondaryPer_ID where c.CallType_ID = '68DD5258F41211D3A3F600A0C9001601' ");
            if (!string.IsNullOrEmpty(Keywords1.Text))
            {
                qrystr.Append("and (e.Summary like '%" + Keywords1.Text + "%' or e.memo like '%" + Keywords1.Text + "%') ");
            }
            if (!string.IsNullOrEmpty(Keywords2.Text))
            {
                qrystr.Append("and (e.Summary like '%" + Keywords2.Text + "%' or e.memo like '%" + Keywords2.Text  + "%') ");
            }
            if (!string.IsNullOrEmpty(SDate.Text))
            {
                qrystr.Append("and c.openDate > '" + SDate.Text + "' ");
            }
            if (!string.IsNullOrEmpty(EDate.Text))
            {
                qrystr.Append("and c.openDate < '" + EDate.Text + "' ");
            }
            if (!string.IsNullOrEmpty(SupportTech.Text))
            {
                qrystr.Append("and e.AddUser like '%" + SupportTech.Text + "%' ");
            }
            if (!string.IsNullOrEmpty(FieldTech.Text))
            {
                qrystr.Append("and p.firstname + ' ' + p.lastname  like '%" + FieldTech.Text + "%' ");
            }
            if (!string.IsNullOrEmpty(Partner.Text))
            {
                qrystr.Append("and o.orgname like '%" + Partner.Text + "%' ");
            }
            if (!string.IsNullOrEmpty(SSN.Text))
            {
                qrystr.Append("and c.SerialNum like '%" + SSN.Text + "%' ");
            }
            if (!string.IsNullOrEmpty(Status.SelectedValue.ToString()))
            {
                qrystr.Append("and IsClosed = " + Status.SelectedValue.ToString());
            }
            qrystr.Append(" group by c.Call_ID, c.Call_Num, o.OrgName, IsNull(c.SerialNum, 'Not Provided'), c.OpenDate,");
            qrystr.Append(" IsNull(c.Summary, 'Summary is not filled out') order by opendate desc");
            //num.Text = qrystr.ToString(); //debugging, writes sql to the header.            
            return qrystr.ToString();
        }
        /// <summary>
        /// Hightlights the input based on keyword entries.
        /// </summary>
        /// <param name="rawdata">The rawdata.</param>
        /// <returns></returns>
        private string Hightlight(string rawdata)
        {
            string highlighteddata = null;
            if (!string.IsNullOrEmpty(Keywords1.Text)) 
            {
                highlighteddata = Regex.Replace(rawdata.ToLower(), Keywords1.Text.ToLower(), "<font Color='Red'><B>" + Keywords1.Text + "</B></font>");
            }            
            if (!string.IsNullOrEmpty(Keywords2.Text)) 
            {
                if (string.IsNullOrEmpty(highlighteddata))
                {
                    highlighteddata = Regex.Replace(rawdata.ToLower(), Keywords2.Text.ToLower(), "<font Color='Blue'><B>" + Keywords2.Text + "</B></font>");
                }
                else
                {
                    highlighteddata = Regex.Replace(highlighteddata.ToLower(), Keywords2.Text.ToLower(), "<font Color='Blue'><B>" + Keywords2.Text + "</B></font>");
                }
            }
            if (string.IsNullOrEmpty(highlighteddata)) { highlighteddata = rawdata; }
            return highlighteddata;
        }
        #endregion
    }
}

Open in new window

0

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question