处理GridView中的多个链接按钮

时间:2018-07-03 16:39:14

标签: c# gridview event-handling aspxgridview

我将在gridview中创建2链接按钮。 (ViewMore和MakeReservation)。我使用switch语句使系统知道用户选择了哪个按钮。

首先,我尝试了if else语句,但是也无法正常工作。

public List<Folder> getsharedFolder() {
    return folderRepository.findBy___();
}

第二,我曾经从if else变成switch

if (e.CommandName == "ViewMore")
{
    List<Restaurant> restaurants = RestaurantDB.getRestaurantByCountry(Session["countryName"].ToString());
    Restaurant r = restaurants[gvRestaurant.SelectedIndex];
    Session["menuItems"] = r;
    Session["menu"] = r.Name;
    Response.Redirect("GetMenuItem.aspx");
}
else if (e.CommandName == "MakeReservation")
{
    List<Restaurant> restaurants = RestaurantDB.getRestaurantByUserSelected(Session["countryName"].ToString(), Session["menu"].ToString());
    Restaurant r = restaurants[gvRestaurant.SelectedIndex];
    Session["menu"] = r.Name;
    Response.Redirect("MakeReservation.aspx");
}

我得到的关于switch语句的错误消息: ->输入的字符串格式不正确。

有什么调试我的代码的想法吗?

谢谢!

0 个答案:

没有答案
相关问题