Click here to Skip to main content
15,919,613 members
Home / Discussions / C#
   

C#

 
QuestionHow to parse/read tabular data from a pdf Pin
dinesh choudhary10-Dec-08 17:24
dinesh choudhary10-Dec-08 17:24 
QuestionConverting data Types? Pin
evilqualar10-Dec-08 14:56
evilqualar10-Dec-08 14:56 
QuestionC# Word Automation - How to extract Rich Text Pin
blochri10-Dec-08 14:02
blochri10-Dec-08 14:02 
AnswerRe: C# Word Automation - How to extract Rich Text Pin
Dave Kreskowiak10-Dec-08 14:33
mveDave Kreskowiak10-Dec-08 14:33 
GeneralRe: C# Word Automation - How to extract Rich Text Pin
blochri11-Dec-08 2:36
blochri11-Dec-08 2:36 
GeneralRe: C# Word Automation - How to extract Rich Text Pin
Dave Kreskowiak11-Dec-08 12:28
mveDave Kreskowiak11-Dec-08 12:28 
GeneralRe: C# Word Automation - How to extract Rich Text Pin
blochri12-Dec-08 3:30
blochri12-Dec-08 3:30 
QuestionGridview search Pin
Andrew Woodward10-Dec-08 10:35
Andrew Woodward10-Dec-08 10:35 
Hi Everyone

I'm new to ASP.NET and am having trouble with my project. I am building it using Visual Web Developer 2008 Express. Language C#.
I have a gridview linked to a LinqDataSource. I want to add a search facility to the gridview as the database that is linked to it contains a lot of entries.

I downloaded the code from your site for the control to do this and altered everything to meet my specifications. Everything seems to work except that the gridview still remains the same with the original entries showing instead of showing the filtered entries.
The gridview shows four columns from the database table.
Hope someone out there can she some light on this as I'm pulling my hair out.

Thanx in anticipation

Andy

My code behind code is this:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;

public partial class Controls_PinsSearch : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void lbtnBasicSearch_Click(object sender, EventArgs e)
    {
        string sSearchText = GetBasicSearchString();
        OnSearch(sSearchText);

        lbtnCancelBasicSearch.Visible = true;
    }
    protected string GetBasicSearchString()
    {
        StringBuilder sb = new StringBuilder(string.Empty);
        string sBasicSearchText = txtBasicSearch.Text.Trim();

        if (sBasicSearchText == string.Empty)
            return string.Empty;

        string sFirstName = GetSearchFormattedFieldString("FirstName", sBasicSearchText, string.Empty, true);
        sb.Append(sFirstName);
        sb.Append(" OR ");

        string sLastName = GetSearchFormattedFieldString("LastName", sBasicSearchText, string.Empty, true);
        sb.Append(sLastName);
        sb.Append(" OR ");

        string sPinCode = GetSearchFormattedFieldString("PinCode", sBasicSearchText, string.Empty, true);
        sb.Append(sPinCode);
        sb.Append(" OR ");

        string sFilter = GetSearchFormattedFieldString("Filter", sBasicSearchText, string.Empty, true);
        sb.Append(sFilter);
        sb.Append(" OR ");



        string sSearch = sb.ToString();
        return sSearch;
    }
    protected string GetSearchFormattedFieldString(string sfield, string value, string soperator, bool bForceStringType)
    {
        if (value.Trim() == string.Empty)
            return string.Empty;

        string _newValue = value.Trim();
        

        string _operator = "=";
        if (soperator != string.Empty)
            _operator = soperator;

          if (bForceStringType == false)
        {
            
        }
        

        return _newValue;
    }
    public delegate void SearchEventHandler(string _SearchText);
    public event SearchEventHandler Search;
    protected virtual void OnSearch(string _SearchText)
    {
        if (Search != null)
        {
            Search(_SearchText);
        }
    }
    protected void lbtnCancelBasicSearch_Click(object sender, EventArgs e)
    {
        txtBasicSearch.Text = string.Empty;
        OnSearch(string.Empty);

        lbtnCancelBasicSearch.Visible = false;
    }
}




The markup code for the control is:

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="PinsSearch.ascx.cs" Inherits="Controls_PinsSearch" %>

<asp:Panel ID="pnlBasicSearch" runat="server" Width="100%">
    <table>
        
        <tr>
            <td>
                <asp:Label ID="lblBasicSearch" runat="server" Text="Search for:"  ></asp:Label>
            </td>
            <td>
                <asp:TextBox ID="txtBasicSearch" runat="server" Text="" MaxLength="50"  Width="255px" />
            </td>
            <td>
                <asp:LinkButton runat="server"  ID="lbtnBasicSearch" CausesValidation="False"  Text="Search" OnClick="lbtnBasicSearch_Click" />
            </td>
            <td>
                <asp:LinkButton runat="server"  ID="lbtnCancelBasicSearch"  CausesValidation="False" Visible="false" Text="Cancel" OnClick="lbtnCancelBasicSearch_Click" />
            </td>
        </tr>
        <tr>
            <td colspan="2" align="right">                
                
            </td>
            <td colspan="2"></td>
        </tr>
    </table>       
</asp:Panel>

AnswerRe: Gridview search Pin
Christian Graus10-Dec-08 12:39
protectorChristian Graus10-Dec-08 12:39 
GeneralRe: Gridview search Pin
Andrew Woodward10-Dec-08 12:43
Andrew Woodward10-Dec-08 12:43 
QuestionCrystal reports charts programmatically? Pin
Priya Prk10-Dec-08 9:03
Priya Prk10-Dec-08 9:03 
AnswerRe: Crystal reports charts programmatically? Pin
Wendelius10-Dec-08 11:07
mentorWendelius10-Dec-08 11:07 
GeneralRe: Crystal reports charts programmatically? Pin
Priya Prk10-Dec-08 23:39
Priya Prk10-Dec-08 23:39 
GeneralRe: Crystal reports charts programmatically? Pin
Wendelius11-Dec-08 4:33
mentorWendelius11-Dec-08 4:33 
QuestionNeed some help loading a treeview [modified] Pin
Rafone10-Dec-08 8:33
Rafone10-Dec-08 8:33 
AnswerRe: Need some help loading a treeview Pin
Christian Graus10-Dec-08 9:18
protectorChristian Graus10-Dec-08 9:18 
GeneralRe: Need some help loading a treeview Pin
Rafone10-Dec-08 10:13
Rafone10-Dec-08 10:13 
GeneralRe: Need some help loading a treeview Pin
Christian Graus10-Dec-08 12:40
protectorChristian Graus10-Dec-08 12:40 
GeneralRe: Need some help loading a treeview Pin
Rafone24-Dec-08 5:13
Rafone24-Dec-08 5:13 
QuestionTwo questions related to Chart Control Pin
Seraph_summer10-Dec-08 5:31
Seraph_summer10-Dec-08 5:31 
AnswerRe: Two questions related to Chart Control Pin
Pete O'Hanlon10-Dec-08 6:02
mvePete O'Hanlon10-Dec-08 6:02 
GeneralRe: Two questions related to Chart Control Pin
led mike10-Dec-08 6:19
led mike10-Dec-08 6:19 
AnswerRe: Two questions related to Chart Control Pin
Rafone10-Dec-08 8:37
Rafone10-Dec-08 8:37 
QuestionScreen Color Quality Pin
Michael Bookatz10-Dec-08 5:28
Michael Bookatz10-Dec-08 5:28 
GeneralRe: Screen Color Quality Pin
Luc Pattyn10-Dec-08 6:05
sitebuilderLuc Pattyn10-Dec-08 6:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.