Click here to Skip to main content
15,886,078 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
my project two drop down list and one button.when i can select the both drop down list different value and click the button then display data in grid view.when drop down list value passed in stored procedure then no any data can be return..
code for click event
C#
protected void btnShow_Click(object sender, EventArgs e)
{
    SqlConnection objConn = new SqlConnection();
    objConn.ConnectionString = ConfigurationManager.ConnectionStrings["Eagle TradelinkConnectionString"].ToString();
    objConn.Open();
    SqlCommand objCmd = objConn.CreateCommand();
    SqlDataAdapter sqladp = new SqlDataAdapter();
    DataSet ds = new DataSet();
    objCmd.CommandType = CommandType.StoredProcedure;
    objCmd.CommandText = "PR_ParcelBooking_SelectByFromCityIDToCityID";
    objCmd.Parameters.Add("@FromCityID", SqlDbType.Int).Value = ddlFromCityID.SelectedValue;
    objCmd.Parameters.Add("@ToCityID", SqlDbType.Int).Value = ddlToCityID.SelectedValue;
    sqladp.SelectCommand = objCmd;
    sqladp.Fill(ds);
    gvCityList.DataSource = ds;
    gvCityList.DataBind();
}

above code any mistake or not..can give me answer
Posted
Updated 8-Mar-13 20:23pm
v2
Comments
Nandakishore G N 9-Mar-13 1:46am    
what is the error did you got?
Ashvinrajkot 9-Mar-13 3:25am    
grid view not display anything
Nandakishore G N 9-Mar-13 3:26am    
check whether the dataset is populating or not after passing values from codebehind.using line by line debugging..
Ashvinrajkot 9-Mar-13 22:17pm    
give me solution?????
Ashvinrajkot 9-Mar-13 22:17pm    
give me solution??

1 solution

Yes, your SP is wrong.

Following needs correction:
SQL
LEFT OUTER JOIN [dbo].[ParcelType] ON [dbo].[ParcelType].[ParcelID] = [dbo].[ParcelBooking].[ParcelTypeID] WHERE [dbo].[ParcelBooking].[FromCityID]="@FromCityID" AND [dbo].[ParcelBooking].[ToCityID]="@ToCityID"

There will be no quotes around the parameters. Do:
SQL
LEFT OUTER JOIN [dbo].[ParcelType] ON [dbo].[ParcelType].[ParcelID] = [dbo].[ParcelBooking].[ParcelTypeID] WHERE [dbo].[ParcelBooking].[FromCityID]=@FromCityID AND [dbo].[ParcelBooking].[ToCityID]=@ToCityID
 
Share this answer
 
Comments
Ashvinrajkot 9-Mar-13 8:27am    
above answer is not solution i can try double inverted comma to solve.. but without double inverted comma i try not solve it...
Sandeep Mewara 9-Mar-13 8:40am    
What?
Ashvinrajkot 9-Mar-13 9:22am    
can give another solution?????????please

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900