Click here to Skip to main content
15,891,567 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: How to display a attached file as a link in a datagrid cell? Pin
_AK_10-Dec-08 19:59
_AK_10-Dec-08 19:59 
QuestionGridview values display as user needed... Pin
codingrocks10-Dec-08 17:47
codingrocks10-Dec-08 17:47 
AnswerRe: Gridview values display as user needed... Pin
Christian Graus10-Dec-08 18:03
protectorChristian Graus10-Dec-08 18:03 
GeneralRe: Gridview values display as user needed... Pin
codingrocks10-Dec-08 18:11
codingrocks10-Dec-08 18:11 
GeneralRe: Gridview values display as user needed... Pin
Christian Graus10-Dec-08 19:24
protectorChristian Graus10-Dec-08 19:24 
AnswerRe: Gridview values display as user needed... Pin
Nishant Singh10-Dec-08 18:31
Nishant Singh10-Dec-08 18:31 
AnswerRe: Gridview values display as user needed... Pin
Abhijit Jana10-Dec-08 18:53
professionalAbhijit Jana10-Dec-08 18:53 
QuestionGridview Search Pin
Andrew Woodward10-Dec-08 10:43
Andrew Woodward10-Dec-08 10:43 
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:20
protectorChristian Graus10-Dec-08 12:20 
GeneralRe: Gridview Search Pin
Andrew Woodward10-Dec-08 12:41
Andrew Woodward10-Dec-08 12:41 
GeneralRe: Gridview Search Pin
Christian Graus10-Dec-08 12:50
protectorChristian Graus10-Dec-08 12:50 
GeneralRe: Gridview Search Pin
Andrew Woodward10-Dec-08 13:57
Andrew Woodward10-Dec-08 13:57 
GeneralRe: Gridview Search Pin
Christian Graus10-Dec-08 14:04
protectorChristian Graus10-Dec-08 14:04 
Questionsend commands on a remote PC Pin
fahadi8610-Dec-08 10:35
fahadi8610-Dec-08 10:35 
AnswerRe: send commands on a remote PC Pin
Christian Graus10-Dec-08 12:36
protectorChristian Graus10-Dec-08 12:36 
AnswerRe: send commands on a remote PC Pin
Abhijit Jana10-Dec-08 18:26
professionalAbhijit Jana10-Dec-08 18:26 
QuestionRetrieve text from a dynamically created textbox Pin
TerRO_GirL10-Dec-08 10:12
TerRO_GirL10-Dec-08 10:12 
AnswerRe: Retrieve text from a dynamically created textbox Pin
led mike10-Dec-08 10:16
led mike10-Dec-08 10:16 
GeneralRe: Retrieve text from a dynamically created textbox Pin
TerRO_GirL10-Dec-08 10:24
TerRO_GirL10-Dec-08 10:24 
GeneralRe: Retrieve text from a dynamically created textbox Pin
led mike10-Dec-08 10:29
led mike10-Dec-08 10:29 
GeneralRe: Retrieve text from a dynamically created textbox Pin
TerRO_GirL10-Dec-08 10:40
TerRO_GirL10-Dec-08 10:40 
GeneralRe: Retrieve text from a dynamically created textbox Pin
TerRO_GirL10-Dec-08 10:56
TerRO_GirL10-Dec-08 10:56 
GeneralRe: Retrieve text from a dynamically created textbox Pin
led mike10-Dec-08 10:58
led mike10-Dec-08 10:58 
GeneralRe: Retrieve text from a dynamically created textbox Pin
TerRO_GirL10-Dec-08 11:04
TerRO_GirL10-Dec-08 11:04 
GeneralRe: Retrieve text from a dynamically created textbox Pin
led mike10-Dec-08 11:50
led mike10-Dec-08 11:50 

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.