如何绑定数据一个条件 [英] How to bind the data one the condition

查看:76
本文介绍了如何绑定数据一个条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个项目表,其中包含不同品牌的项目.现在,我希望在下订单时仅将一个品牌的商品显示给该brandadmin.例如,xyz品牌商品只能由xyz管理员订购.但是xyz的某些品牌也可以由abc订购.

I have a items table which contains the items of diffrent brands . Now i want that when order is placed the item of one brand is shown to that brandadmin only . For example xyz brand item can be ordered by xyz admin only . But some of the brand of xyz can be order by abc also .

推荐答案

您可以通过定义roleId来实现,在按会话加载页面期间,您可以传递rloeid ,如果用户具有特定产品的角色,那么他可以打开,否则无法打开,为此,在创建用户ID期间,您还应该同时充当Roleeid,并且在登录页面时,您可以获取角色ID;
有些代码对您有帮助,
字符串strCurrentRole;

You Can Do This Via define the roleId, during page load by session you can pass the rloeid, If a user have role for particular product, then he can open otherwise he can''t,for this during create user id you should be paas the roleeid also, and during login the page you can fetch the role id;
there is some code that will be helpfull for you,
string strCurrentRole;

try
{
    strCurrentRole = Request.QueryString["RoleId"].ToString();
    if (Session["Admin"] == null || strCurrentRole != "11" || Session["Roles"].ToString().IndexOf("11") == -1)
    {
        Session.RemoveAll();
        Response.Redirect("Default.aspx");
    }
}
catch
{
    Session.RemoveAll();
    Response.Redirect("Default.aspx");
}



代码格式.



Code formatted.


这篇关于如何绑定数据一个条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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