下拉列表没有填写 [英] dropdown list is not filling

查看:108
本文介绍了下拉列表没有填写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在尝试填写我的下拉列表中选定的索引更改事件

第一个下拉列表但我的代码无效。

我希望在选择depocode时,只有该depo的批次代码将填写批次代码dll。



C#文件中的代码:

  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 (例外情况)
{
}
终于
{
}

}



Bussines逻辑代码:

  protected   void  ddlDepot_SelectedIndexChanged(对象发​​件人,EventArgs e)
{
尝试
{
FillLot_Code(ddllotcode);
}
catch (例外情况)
{
}
最后
{
}

}



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  [dbo]。[SP_tr_LotCreation_SelectLot]( @ DIV_ID   int  @ Depot_Code   char 

AS
BEGIN
- 添加SET NOCOUNT ON以防止额外的结果集
- 干扰SELECT语句。
SET NOCOUNT ON ;

选择 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
来自 dbo.Lot_Creation
其中 Sold_Status = < span class =code-string>' U' dbo.Lot_Creation.DIV_ID = @ DIV_ID dbo.Lot_Creation.Depot_Code = @ Depot_Code

ORDER BY Lot_Creation.Lot_Code

END





我应该更改什么?



谢谢



已添加代码块[/ Edit]

解决方案

像Zafar所说,确保首先从数据库中获取数据。由于我们都无法访问您的数据库,因此我们无法测试您的函数以查看它们返回的内容。



我首先会在该行上设置断点:



 ddllotcode.DataSource = dt; 





检查返回的值。如果代码永远不会到达断点,那么''on change''事件可能甚至无法正常触发。如果数据按预期返回,您知道问题在于将结果绑定到页面。


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]

解决方案

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.


这篇关于下拉列表没有填写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆