wangjie627542389
2015-12-11 07:42 阅读 1.5k

ASP中的<asp:Repeater>控件问题

各位大神们好,我在项目中使用asp:Repeater控件,去显示我数据库里面的数据,可是运行程序的时候显示:图片说明

我把代码给大家看一下,请大家帮我看看是哪里出了错误

(1)前台页面数据绑定:





























序号

I级机构

II级机构

III级机构



<%#Eval("Id") %>>

<%#Eval("Csk_no.Cfk_no.First_kind_name") %>>

<%#Eval("Csk_no.Second_kind_name") %>>

<%#Eval("Third_kind_name") %>>

修改
onclick="return confirm('确定要删除吗?');">删除


/asp:Repeater

(2)获得数据源的BLL层方法代码:

public static IList GetAllConfig_file_third_kinds()
{
return Config_file_third_kindService.GetAllConfig_file_third_kinds();
}

    public static Config_file_third_kind GetConfig_file_third_kindById(int id)
    {
        return Config_file_third_kindService.GetConfig_file_third_kindById(id);
    }

(3)DAL层代码:

 public static IList<Config_file_third_kind> GetAllConfig_file_third_kinds()
    {
        string sqlAll = "SELECT * FROM Config_file_third_kind";
        return GetConfig_file_third_kindsBySql(sqlAll);
    }

    public static Config_file_third_kind GetConfig_file_third_kindById(int id)
    {
        string sql = "SELECT * FROM Config_file_third_kind WHERE Id = @Id";

        int csk_no;

        try
        {
            SqlDataReader reader = DBHelper.GetReader(sql, new SqlParameter("@Id", id));
            if (reader.Read())
            {

                Config_file_third_kind config_file_third_kind = new Config_file_third_kind();

                try
                {
                    config_file_third_kind.Id = (int)reader["Id"];
                }
                catch
                { }
                try
                {
                    config_file_third_kind.Third_kind_no = (string)reader["Third_kind_no"];
                }
                catch
                { }
                try
                {
                    config_file_third_kind.Third_kind_name = (string)reader["Third_kind_name"];
                }
                catch
                { }
                try
                {
                    config_file_third_kind.Third_kind_salary_no = (string)reader["Third_kind_salary_no"];
                }
                catch
                { }
                try
                {
                    config_file_third_kind.Third_kind_is_retail = (string)reader["Third_kind_is_retail"];
                }
                catch
                { }
                csk_no = (int)reader["Csk_no"]; //FK

                reader.Close();

                config_file_third_kind.Csk_no = Config_file_second_kindService.GetConfig_file_second_kindById(csk_no);

                return config_file_third_kind;
            }
            else
            {
                reader.Close();
                return null;
            }
        }
        catch (Exception e)
        {
            Console.WriteLine(e.Message);
            throw e;
        }
    }



            请各位大神帮我看看,拜托了,拜托了
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

2条回答 默认 最新

  • devmiao devmiao 2015-12-11 20:00

    对象为null,检查下代码

    点赞 1 评论 复制链接分享
  • MsdnWoo MsdnWoo 2015-12-20 16:07

    asp:Repeater控件就相当于,for循环
    你自己在出错前后加上断点,调试下,看是否能够得到对象

    点赞 评论 复制链接分享

相关推荐