| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 699 人关注过本帖
标题:gridview里不能显示链接
取消只看楼主 加入收藏
泡泡喜欢
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2011-2-16
结帖率:100%
收藏
已结贴  问题点数:5 回复次数:4 
gridview里不能显示链接

我有一段程序把if (userid != 902)改成
userinfo = userbll.GetAllRegisterInfoByID(userid);
 if (userinfo.LoginName != "123")就可以显示链接了 但是我不明白是怎么回事 其他程序也是不能显示gridview里的链接 我就不会改了 请各位高手帮忙


下面有全部后台代码

[ 本帖最后由 泡泡喜欢 于 2011-2-17 17:00 编辑 ]
2011-02-16 11:28
泡泡喜欢
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2011-2-16
收藏
得分:0 
回复 2楼 qingshuiliu
给您发的邮件 谢谢啦
2011-02-16 13:35
泡泡喜欢
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2011-2-16
收藏
得分:0 
回复 4楼 冰镇柠檬汁儿
代码好多

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using OANew.BLL;
using OANew.Model;

namespace OANew.Web.
{
    public partial class DepartmentExamines : System.Web.UI.Page
    {
        CompanyOa co = new CompanyOa();
        CompanyOaBll cobll = new CompanyOaBll();
        EmployeesDepartmentNew dep = new EmployeesDepartmentNew();
        EmployeesDepartmentNewBll depbll = new EmployeesDepartmentNewBll();
        Bull bull = new Bull();
        BullBll bullbll = new BullBll();
        UserRegisteredInfo userinfo = new UserRegisteredInfo();
        UserRegisteredInfoBll userinfobll = new UserRegisteredInfoBll();
        OaNewRole role = new OaNewRole();
        OaNewRoleBll rolebll = new OaNewRoleBll();
        EmployeesDepartmentMemberNew depmember = new EmployeesDepartmentMemberNew();
        EmployeesDepartmentMemberNewBll depmemberbll = new EmployeesDepartmentMemberNewBll();
        CompanyOaManager com = new CompanyOaManager();
        CompanyOaManagerBll combll = new CompanyOaManagerBll();
        OaNewPermission permission = new OaNewPermission();
        OaNewPermissionBll permissionbll = new OaNewPermissionBll();
        OaNewUserToGroupMap onutgm = new OaNewUserToGroupMap();
        OaNewUserToGroupMapBll onutgmbll = new OaNewUserToGroupMapBll();
        UserRegisteredInfo depinfo = new UserRegisteredInfo();
        CompanyOaBll companyno = new CompanyOaBll();
        string companyoanumber;
        string employeesdepartmentname;
        int companyid;
        ArrayList a;
        int userid;
        bool m;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (this.Request.QueryString["companyid"] == null)
            {
                Response.Redirect("../../Login.aspx");
            }
            else
            {
                companyoanumber = this.Session["companyoanumber"].ToString();
                employeesdepartmentname = Session["employeesdepartmentname"].ToString();
                userid = int.Parse(this.Session["userid"].ToString());
                bull = bullbll.GetBullInfoById(userid);
                companyid = int.Parse(this.Request.QueryString["companyid"].ToString());
                bind();
                bindpermission();
            }
        }

        private void bind()
        {
            co = cobll.GetCompanyInfoByCompanyTail(companyid);
            TextBox4.Text =
            string tail = ();
            int j = tail.Length;
            for (int i = 5 - j; i > 0; i--)
            {
                tail = "0" + tail;
            }
            string companyno = + tail;

            DataTable dt = depbll.GetAllDepartmentInfo(companyno);
            GridView1.DataSource = dt;
            GridView1.DataBind();
        }
        private void bindpermission()
        {
            if (userid != 902)
                        {
                dep = depbll.GetDepartmentInfoByDepNameAndCompanyno(employeesdepartmentname, companyoanumber);
                DataTable dt = onutgmbll.GetOaNewUserToGroupMapInfoByCardAndDepId(bull.BlessingCardNumber, dep.EmployeesDepartmentId);
                Button1.Visible = false;
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    int groupid = int.Parse(dt.Rows[i]["OaUserGroupId"].ToString());
                    DataTable dt1 = permissionbll.GetOaNewPermissionInfoByOaUserGroupId(groupid);
                    for (int j = 0; j < dt1.Rows.Count; j++)
                    {
                        string flag = dt1.Rows[j]["Flag"].ToString();
                        if (flag.Substring(2, 2) + flag.Substring(4, 2) == "B1C1")  //添加
                        {
                            Button1.Visible = true;
                        }

                    }
                }
            }
        }

        public string GetDepNumber(int id)  //得到部门编码
        {
            dep=depbll.GetDepartmentInfoByDepId(id);
            string depnumber=dep.EmployeesDepartmentId.ToString();
            int j = depnumber.Length;
            for (int i = 5 - j; i > 0; i--)
            {
                depnumber = "0" + depnumber;
            }
            return dep.DepartmentNoHeader + depnumber;
        }

        

        public string GetDepMenager(string card)  //得到该部门主管
        {
            if (card == "")
            {
                return "";
            }
            else
            {
                bull = bullbll.GetUserByCard(card);
                userinfo = userinfobll.GetAllRegisterInfoByID(bull.Id);
                return userinfo.TrueName;
            }
        }


        public string GetTime(int id)
        {
            dep = depbll.GetDepartmentInfoByDepId(id);
            return dep.DepartmenDate.ToString().Split(' ')[0];
        }
        protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            GridView1.PageIndex = e.NewPageIndex;
            GridView1.DataBind();
        }

        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int id = int.Parse(());
            switch()
            {
                case "edit":       //编辑部门
                    {
                        string scriptStr = "location.replace('AddDepartment.aspx?companyid=" + companyid + "&type=" + 1 + "&depid=" + id + "');";
                        ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "click", scriptStr, true);
                        break;
                    }
                case "edit1":       //编辑部门员工
                    {
                        string scriptStr = "location.replace('AddDepartmentMember.aspx?companyid=" + companyid + "&depid=" + id + "');";
                        ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "click", scriptStr, true);
                        //Response.Redirect(string.Format("AddDepartmentMember.aspx?companyid={0}&depid={1}", companyid, id), true);
                        break;
                    }
                case "edit2":       //编辑部门职位
                    {
                        string scriptStr = "location.replace('RoleExamine.aspx?companyid=" + companyid + "&depid=" + id + "');";
                        ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "click", scriptStr, true);
                        //Response.Redirect(string.Format("RoleExamine.aspx?companyid={0}&depid={1}", companyid, id), true);
                        break;
                    }
                case "edit3":       //编辑部门主管
                    {
                        string scriptStr = "location.replace('AddDepartmentManager.aspx?companyid=" + companyid + "&depid=" + id + "');";
                        ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "click", scriptStr, true);
                        //Response.Redirect(string.Format("AddDepartmentManager.aspx?companyid={0}&depid={1}", companyid, id), true);
                        break;
                    }
                case "edit5":       //设置默认部门
                    {
                        string scriptStr = "location.replace('AddDefaultDepartment.aspx?companyid=" + companyid + "&depid=" + id + "');";
                        ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "click", scriptStr, true);
                        //Response.Redirect(string.Format("AddDepartmentManager.aspx?companyid={0}&depid={1}", companyid, id), true);
                        break;
                    }
                case "edit4":       //查看部门员工
                    {
                        string scriptStr = "location.replace('ExamineDepartmentMember.aspx?companyid=" + companyid + "&depid=" + id + "');";
                        ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "click", scriptStr, true);
                        //Response.Redirect(string.Format("ExamineDepartmentMember.aspx?companyid={0}&depid={1}", companyid, id), true);
                        break;
                    }
                case "del":       //删除部门
                    {
                        bool isok = false;
                        dep = depbll.GetDepartmentInfoByDepId(id);
                        string depno = dep.EmployeesDepartmentId.ToString();
                        int j1 = depno.Length;
                        for (int k1 = 5 - j1; k1 > 0; k1--)
                        {
                            depno = "0" + depno;
                        }
                        string depnumber = dep.DepartmentNoHeader + depno;  //部门编号

                        DataTable codt = cobll.GetAllCompanyInfoByDepNumber(depnumber);
                        for (int m = 0; m < codt.Rows.Count; m++)
                        {
                            int companyid1 = int.Parse(codt.Rows[m]["CompanyOaNoTail"].ToString());
                            co = cobll.GetCompanyInfoByCompanyTail(companyid1);
                            string tail1 = ();
                            int j2 = tail1.Length;
                            for (int k1 = 51 - j2; k1 > 0; k1--)
                            {
                                tail1 = "0" + tail1;
                            }
                            string companyno1 = + tail1;  //公司编号

                            DataTable dt2 = depbll.GetAllDepartmentInfo(companyno1);

                            for (int i2 = 0; i2 < dt2.Rows.Count; i2++)
                            {
                                int depid1 = int.Parse(dt2.Rows[i2]["EmployeesDepartmentId"].ToString());
                                if (depmemberbll.CheckDepartmentMemberByDepid(depid1))
                                {
                                    depmemberbll.DeleteDepartmentMemberByDepId(depid1);//删除EmployeesDepartmentMemberNew
                                    isok = true;
                                }
                                OaNewUserGroupBll usergroupbll=new OaNewUserGroupBll();
                                if (usergroupbll.CheckUserGroupByDepid(depid1))
                                {
                                    usergroupbll.DeleteUserGroupByDepid(depid1);
                                }
                                if (rolebll.CheckRoleByDepid(depid1))
                                {
                                    rolebll.DeleteRoleByDepid(depid1);  //删除OaNewRole
                                    isok = true;
                                }
                            }

                            if (depbll.CheckDepartmentNameByCompanyno(companyno1))
                            {
                                depbll.DeleteDepartmentByCompanyNo(companyno1);  //删除EmployeesDepartmentNew
                                isok = true;
                            }

                            if (combll.CheckCompanyManagerByCompanyId(companyid1))
                            {
                                combll.DeleteCompanyManagerByTail(companyid1);   //删除CompanyOaManager
                                isok = true;
                            }
                            if (cobll.DeleteCompany(companyid1))   //删除CompanyOa
                            {
                                isok = true;
                            }

                        }
                        if (depmemberbll.CheckDepartmentMemberByDepid(id))
                        {
                            if (depmemberbll.DeleteDepartmentMemberByDepId(id))
                            {
                                isok = true;
                            }
                        }
                        if (rolebll.CheckRoleByDepid(id))
                        {
                            if (rolebll.DeleteRoleByDepid(id))
                            {
                                isok = true;
                            }
                        }
                        if (depbll.DeleteDepartmentByDepId(id))
                        {
                            isok = true;
                        }
                        if (isok)
                        {
                            ScriptManager.RegisterClientScriptBlock(UpdatePanel1, UpdatePanel1.GetType(), "message", "alert('操作成功!')", true);
                           
                        }
                        else
                        {
                            ScriptManager.RegisterClientScriptBlock(UpdatePanel1, UpdatePanel1.GetType(), "message", "alert('操作失败!')", true);
                           
                        }
                        bind();
                        break;
                    }
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            Response.Redirect(string.Format("AddDepartment.aspx?companyid={0}&type={1}", companyid, 0), true);
        }

        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                /*代码测试分页后不能正确运行,已纠正

                 LinkButton lkbDel = (LinkButton)e.Row.FindControl("DelButton");
                 lkbDel.Attributes.Add("OnClick", "javascript:return confirm('是否要删除该记录? " + this.GridView1.DataKeys[e.Row.DataItemIndex].Value + "')");

     */

                //以下为分页后正常绑定删除确认对话框脚本代码

                LinkButton lkbDel = (LinkButton)e.Row.FindControl("LinkButton4");
                int CurrentPageIndex = this.GridView1.PageIndex;
                int CurrentPageSize = this.GridView1.PageSize;
                int CurrentDateItem = e.Row.DataItemIndex - CurrentPageIndex * CurrentPageSize;
                lkbDel.Attributes.Add("OnClick", "javascript:return confirm('是否要删除该记录?')");


            }
        }

        protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow ||
               e.Row.RowType == DataControlRowType.Header)
            {
                if (userid != 902)
               
                {
                    e.Row.Cells[4].Visible = false;
                    e.Row.Cells[5].Visible = false;

                    e.Row.Cells[6].Visible = false;    //如果想使第1列不可见,则将它的可见性设为false
                    e.Row.Cells[7].Visible = false;
                    e.Row.Cells[8].Visible = false;
                    e.Row.Cells[9].Visible = false;
                    e.Row.Cells[10].Visible = false;

                    DataTable dt = onutgmbll.GetOaNewUserToGroupMapInfoByCardAndDepId(bull.BlessingCardNumber, dep.EmployeesDepartmentId);

                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        int groupid = int.Parse(dt.Rows[i]["OaUserGroupId"].ToString());
                        DataTable dt1 = permissionbll.GetOaNewPermissionInfoByOaUserGroupId(groupid);
                        for (int j = 0; j < dt1.Rows.Count; j++)
                        {
                            string flag = dt1.Rows[j]["Flag"].ToString();

                            if (flag.Substring(2, 2) + flag.Substring(4, 2) == "B1C1")  //增加
                            {
                                e.Row.Cells[5].Visible = true;
                                e.Row.Cells[6].Visible = true;
                                e.Row.Cells[7].Visible = true;
                                e.Row.Cells[8].Visible = true;
                            }
                            if (flag.Substring(2, 2) + flag.Substring(4, 2) == "B1C2")  //删除
                            {
                                e.Row.Cells[10].Visible = true;
                            }
                            if (flag.Substring(2, 2) + flag.Substring(4, 2) == "B1C3")  //修改
                            {
                                e.Row.Cells[4].Visible = true;
                            }
                            if (flag.Substring(2, 2) + flag.Substring(4, 2) == "B1C4")  //查询
                            {
                                e.Row.Cells[9].Visible = true;
                            }

                        }
                    }
                }
            }
        }

        protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
        {

        }
    }
}
2011-02-17 14:35
泡泡喜欢
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2011-2-16
收藏
得分:0 
没人回复呀
2011-02-17 16:59
泡泡喜欢
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2011-2-16
收藏
得分:0 
主要是实例化的问题 还有if里用的什么条件
2011-02-18 11:33
快速回复:gridview里不能显示链接
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.057704 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved