Click here to Skip to main content
11,805,604 members (56,326 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: ASP.NET
in my project using text box enter value successful search using sql server database but i can also use the drop down list . when the drop down list one value select and this value pass the data base and match the data in data base and this record return the value in grid view. how can do it.and my project like as two text box,one dropdown control.when ever without enter textbox value or no select drop down then return all the data. when one textbox and drop down select then matched data return.
Posted 27-Mar-13 6:07am
Edited 28-Mar-13 7:32am
richcb at 27-Mar-13 12:20pm
I know English is not your primary language, but you will need to try and clarify your thread. It makes no sense and you won't get much help on it.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Ashvinrajkot at 28-Mar-13 11:49am
any one can give my question answer???
ThePhantomUpvoter at 28-Mar-13 12:21pm
Probably someone could, you need to clarify your question like you have already been told. Post the code that you have written that demonstrates your problem and then describe the problem that you have. At least Abhinav tried to answer you.
Ashvinrajkot at 28-Mar-13 12:34pm
i can not use sqldatasource .here i can use aspx.cs file code write
ThePhantomUpvoter at 28-Mar-13 12:52pm
Okay... and what exactly does that have to do with anything?
Ashvinrajkot at 28-Mar-13 13:22pm
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

public partial class AdminPanel_ParcelLoadingUnLoading_ParcelLoadingUnLoadingSearch : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)

protected void btnSearch_Click(object sender, EventArgs e)
SqlConnection objConn = new SqlConnection();
objConn.ConnectionString = ConfigurationManager.ConnectionStrings["Eagle TradelinkConnectionString"].ToString();
SqlCommand objCmd = objConn.CreateCommand();
objCmd.CommandType = CommandType.Text;
objCmd.CommandText =@"select BranchName,ReceivedPersonName
from LEFT OUTER JOIN [dbo].[Branch] ON [dbo].[Branch].[BranchID] = [dbo].[ParcelDelivery].[BranchID]
ParcelDelivery where BranchName like '%" + Convert.ToInt32(ddlBranchID.SelectedValue) + "%' and ReceivedPersonName like '%" + txtReceivedPersonName.Text + "%'";
string name = "";
if (txtReceivedPersonName.Text !="")
name = name + "ReceivedPersonName like '%" + txtReceivedPersonName.Text + "%' ";
if (ddlBranchID.SelectedValue>0)
if (name != "")
name += "and";
name = name + "BranchName like '%" + Convert.ToInt32(ddlBranchID.SelectedValue.ToString) + "%'";
objCmd.Parameters.AddWithValue("@ReceivedPersonName", SqlDbType.Text).Value = name.ToString();
objCmd.Parameters.AddWithValue("@BranchName", SqlDbType.Int).Value = name.ToString();
DataSet Objds = new DataSet();
SqlDataAdapter Objsda = new SqlDataAdapter();
Objsda.SelectCommand = objCmd;
gvSearchResult.DataSource = Objds;
error can generate like this Operator '>' cannot be applied to operands of type 'string' and 'int'
aboe code error in drop downlist coding..
ThePhantomUpvoter at 28-Mar-13 15:20pm
And where does this error come from? You are not using > anywhere in this code so.... And the error means exactly what it says, a string cannot be compared to an int by using >. A string could not be greater than, less than or equal to any integer. And to top it all off, this is a button click event not a drop down list anything.
Ashvinrajkot at 29-Mar-13 0:44am

In command text ddl branch id.selected value not pass the value can select the dropdown list

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 300
1 Richard Deeming 225
2 Sergey Alexandrovich Kryukov 170
3 ppolymorphe 125
4 Abhinav S 118
0 OriginalGriff 3,300
1 Maciej Los 1,990
2 KrunalRohit 1,907
3 CPallini 1,855
4 Richard MacCutchan 1,227

Advertise | Privacy | Mobile
Web04 | 2.8.151002.1 | Last Updated 28 Mar 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100