本文介绍了中继器单击“问题”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试以下代码时出错。

错误消息:值不能为空。参数名称:source



这些是我收到错误的行。



FoodTypeResponseDto selectedFoodTypes = this .FoodTypes.FirstOrDefault(r => r.FoodTypeId == foodTypeID);



如何整理出来?



提前致谢。



I have got an error when try the following code.
Error Message: Value cannot be null. Parameter name: source

These are the lines where I got the error.

FoodTypeResponseDto selectedFoodTypes = this.FoodTypes.FirstOrDefault(r => r.FoodTypeId == foodTypeID);

How to sort it out?

Thanks in advance.

protected void RecipeManagementUserControl_RepeaterItemClick(object sender, CommandEventArgs e)
{

        if (e.CommandName == WellKnownCommandNames.Edit.ToString())
        {

            int foodTypeID = 0;
            if (!string.IsNullOrEmpty(e.CommandArgument.ToString()))
            {
                int.TryParse(e.CommandArgument.ToString(), out foodTypeID);

                this.FoodTypeID = foodTypeID;
                this.FoodType = ((LinkButton)(((RepeaterCommandEventArgs)(e)).CommandSource)).Text;

                LinkButton linkButton = (LinkButton)FindControl("foodTypeActionLinkButton");

                FoodTypeResponseDto selectedFoodTypes = this.FoodTypes.FirstOrDefault(r => r.FoodTypeId == foodTypeID);

                this.FoodType = selectedFoodTypes.Name;
                this.FoodTypeIndexID = selectedFoodTypes.IndexID;

                this.GetMultipleFoodData();
            }
        }
}

推荐答案


这篇关于中继器单击“问题”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 01:47