Click here to Skip to main content
11,492,385 members (64,212 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
Hi,
I am trying to fill my dropdown list on selected index changed event of
first dropdown list but my code is not working.
I want that on selection of depocode only lot code of that depo will be filled in the lot code dll.

Code in C# file:
 protected void FillLot_Code(DropDownList ddllotcode)
    {
        try
        {
            DataTable dt = new DataTable();
            dt = objLotCreation.SelectLot(Convert.ToInt32(Session["OfficeID"].ToString()),ddlDepot.SelectedValue);
            ddllotcode.DataSource = dt;
                     
            ddllotcode.DataTextField = "Lot_Code";
            ddllotcode.DataValueField = "Lot_Code";
            ddllotcode.DataBind();
            ListItem lstlotcode = new ListItem(Resources.Language.Common_Select, "0");
            ddllotcode.Items.Insert(0, lstlotcode);
        }
        catch (Exception ex)
        {
        }
        finally
        {
        }
 
    }
Bussines logic code:
protected void ddlDepot_SelectedIndexChanged(object sender, EventArgs e)
    {
        try
        {
            FillLot_Code(ddllotcode);
        }
        catch (Exception ex)
        {
        }
        finally
        {
        }
 
    }
 

 
public DataTable SelectLot(int DIV_ID, string Depot_Code)
        {
            ArrayList lstParam = new System.Collections.ArrayList();
            SqlParameter param;
 
            param = new SqlParameter();
            param.ParameterName = "@DIV_ID";
            param.SqlDbType = SqlDbType.Int;
            param.Value = DIV_ID;
            lstParam.Add(param);
 
            param = new SqlParameter();
            param.ParameterName = "@Depot_Code";
            param.SqlDbType = SqlDbType.Char;
            param.Value = Depot_Code;
            lstParam.Add(param);
 
            return (new eAuctionDAL.SQLDAL().SelectData("SP_tr_LotCreation_SelectLot", lstParam, false));
        }

procedure :
create PROCEDURE [dbo].[SP_tr_LotCreation_SelectLot](@DIV_ID int,@Depot_Code char)
 
AS
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;
 
select Depot_Code, Lot_Code,Depo_stackno,SPECIES_Ename,SPECIES_Uname,SPECIES_Kname,Grade,No_of_pieces,
                Length_class,Girth_class,Cubic_meter,Upset_price,Sale_Price,DIV_ID,Sold_Status
  from dbo.Lot_Creation
  where  Sold_Status = 'U' and dbo.Lot_Creation.DIV_ID = @DIV_ID and dbo.Lot_Creation.Depot_Code = @Depot_Code
 
ORDER BY Lot_Creation.Lot_Code
 
END

What should I change?

Thanks

[Edit]Code block added[/Edit]
Posted 28-Dec-12 5:01am
Edited 28-Dec-12 5:05am
v2
Comments
Zafar Sultan at 28-Dec-12 10:05am
   
Are you able to get the list from Database? I mean, have you tried executing your stored procedure with passing parameter explicitly?
ruby kaur at 29-Dec-12 3:32am
   
Thanks Mr. Zafar
I execute my procedure explicitly and got the mistake. Thanks for reminding me this step.

1 solution

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

Solution 1

Like Zafar says, make sure you are getting the data back from the database first. Since none of us has access to your database, we cannot test your functions to see what they're returning.

I would first put a breakpoint on the line:

            ddllotcode.DataSource = dt;

Check the values that are getting returned. If the code never reaches the breakpoint, it's likely the 'on change' event is not even firing properly. If the data is returning as expected, you know the problem lies in binding the results to the page.
  Permalink  
v2

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 455
1 Maciej Los 306
2 Sascha Lefèvre 265
3 Andy Lanng 235
4 KarstenK 220
0 Sergey Alexandrovich Kryukov 9,943
1 OriginalGriff 8,610
2 Sascha Lefèvre 3,609
3 Maciej Los 3,372
4 Richard Deeming 2,440


Advertise | Privacy | Mobile
Web04 | 2.8.150520.1 | Last Updated 28 Dec 2012
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