Click here to Skip to main content
15,878,852 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Apply them only in content page. Pin
pss.srinivasan16-Nov-09 20:12
pss.srinivasan16-Nov-09 20:12 
GeneralRe: Apply them only in content page. [modified] Pin
sashidhar16-Nov-09 20:18
sashidhar16-Nov-09 20:18 
GeneralRe: Apply them only in content page. Pin
pss.srinivasan16-Nov-09 20:30
pss.srinivasan16-Nov-09 20:30 
GeneralRe: Apply them only in content page. Pin
sashidhar16-Nov-09 20:31
sashidhar16-Nov-09 20:31 
AnswerRe: Apply them only in content page. Pin
RajpootRohan16-Nov-09 20:20
professionalRajpootRohan16-Nov-09 20:20 
GeneralRe: Apply them only in content page. Pin
pss.srinivasan16-Nov-09 22:28
pss.srinivasan16-Nov-09 22:28 
GeneralRe: Apply them only in content page. [modified] Pin
RajpootRohan16-Nov-09 23:41
professionalRajpootRohan16-Nov-09 23:41 
QuestionAdvanced search .... Pin
RajpootRohan16-Nov-09 19:54
professionalRajpootRohan16-Nov-09 19:54 
Hi to all,

I am working on an advanced search module. It consist of 6 fields given to user to fill and search. The user can fill any one or two and may be all the fields to search. Some fields are text based and some are float.

The logic is that after taking the input, the application should check which fields are filled up by the user. And neglect the fields which are not filled from the sql query.

What I did is that, I fetched all the values from the textboxes and the values which are not empty has been added to a arraylist. Now I got the filledup values. But application will know that it is productid, description or what...

Please assist me.
protected void Button1_Click(object sender, EventArgs e)
{

        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["newcon"].ConnectionString);
        SqlCommand cmd = new SqlCommand();
        cmd.Connection = con;

    //find out which feilds are not null, then make search on the basis of those feilds
    //Now the feilds which are not empty are:

        ArrayList arl = new ArrayList();
        if (TextBox1.Text.Trim() != "")
    {
        arl.Add("productid");
    }
        if (TextBox2.Text.Trim() != "")
    {
        arl.Add("sh_desc");
    }
        if (TextBox3.Text.Trim() != "")
    {
        arl.Add("weight");
    }
        if (TextBox4.Text.Trim() != "")
    {
        arl.Add("length");
    }
        if (TextBox5.Text.Trim() != "")
    {
        arl.Add("width");
    }
        if (TextBox6.Text.Trim() != "")
    {
        arl.Add("height");
    }

    //Now take out the items from the arraylist

    for (int i = 0; i <= arl.Count; i++ )
    {
        if (arl[i].ToString().StartsWith("productid"))
        {

        }
    }
    cmd.CommandText = "select sh_desc,productid,price from PRODUCTS where ";

        cmd.Connection.Open();

        dt = new DataTable();
        dt.Columns.Add("REF", typeof(string));
        dt.Columns.Add("Description", typeof(string));
        dt.Columns.Add("Price", typeof(float));
        SqlDataReader rdr = cmd.ExecuteReader();
        while (rdr.Read())
        {
            pr_id = (rdr["productid"]).ToString();
            testsh_desc = (rdr["sh_desc"]).ToString();
            test_price = Convert.ToSingle(rdr["price"]);

            DataRow myrow = dt.NewRow();

            myrow["REF"] = pr_id;
            myrow["Description"] = testsh_desc;
            myrow["Price"] = test_price;

            dt.Rows.Add(myrow);
            dt.AcceptChanges();
            Session["sear"] = dt;
        }

        if (testsh_desc != null)
        {
            Response.Redirect("~/Results.aspx");
        }
        else
        {
            Response.Redirect("~/ErrorResult.aspx");
        }
        cmd.Connection.Close();
}


cheers,
sneha

AnswerRe: Advanced search .... Pin
Amit Patel198516-Nov-09 19:58
Amit Patel198516-Nov-09 19:58 
GeneralRe: Advanced search .... Pin
RajpootRohan16-Nov-09 20:04
professionalRajpootRohan16-Nov-09 20:04 
AnswerRe: Advanced search .... Pin
Amit Patel198516-Nov-09 20:23
Amit Patel198516-Nov-09 20:23 
AnswerRe: Advanced search .... Pin
Christian Graus16-Nov-09 20:09
protectorChristian Graus16-Nov-09 20:09 
GeneralRe: Advanced search .... Pin
RajpootRohan16-Nov-09 20:17
professionalRajpootRohan16-Nov-09 20:17 
GeneralRe: Advanced search .... Pin
Amit Patel198516-Nov-09 20:24
Amit Patel198516-Nov-09 20:24 
GeneralRe: Advanced search .... Pin
RajpootRohan16-Nov-09 20:31
professionalRajpootRohan16-Nov-09 20:31 
AnswerRe: Advanced search .... Pin
Amit Patel198516-Nov-09 20:31
Amit Patel198516-Nov-09 20:31 
AnswerRe: Advanced search .... Pin
sashidhar16-Nov-09 20:32
sashidhar16-Nov-09 20:32 
GeneralRe: Advanced search .... Pin
RajpootRohan16-Nov-09 21:38
professionalRajpootRohan16-Nov-09 21:38 
GeneralRe: Advanced search .... Pin
sashidhar16-Nov-09 21:45
sashidhar16-Nov-09 21:45 
GeneralRe: Advanced search .... Pin
sashidhar16-Nov-09 22:07
sashidhar16-Nov-09 22:07 
QuestionSession management Pin
Amit Patel198516-Nov-09 19:43
Amit Patel198516-Nov-09 19:43 
AnswerRe: Session management Pin
Christian Graus16-Nov-09 20:11
protectorChristian Graus16-Nov-09 20:11 
GeneralRe: Session management Pin
Amit Patel198516-Nov-09 20:27
Amit Patel198516-Nov-09 20:27 
GeneralRe: Session management Pin
Abhijit Jana16-Nov-09 20:31
professionalAbhijit Jana16-Nov-09 20:31 
Questionfull text search example implement in .net Pin
Member 287607116-Nov-09 19:42
Member 287607116-Nov-09 19:42 

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.