Example #1
0
    protected void gvAttachment_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            string      SavePath      = null;
            ImageButton imgAttachment = (ImageButton)e.Row.FindControl("imgAttachment");
            SavePath = Server.MapPath("\\" + System.Configuration.ConfigurationManager.AppSettings["Info_Path"].ToString());
            string File_ID = DataBinder.Eval(e.Row.DataItem, "File_Id").ToString();
            File_ID = File_ID.PadLeft(8, '0');
            string F1       = Mid(File_ID, 0, 2);
            string F2       = Mid(File_ID, 2, 2);
            string F3       = Mid(File_ID, 4, 2);
            string filePath = SavePath + F1 + @"\" + F2 + @"\" + F3 + @"\" + DataBinder.Eval(e.Row.DataItem, "File_Path").ToString();
            imgAttachment.CommandArgument = filePath;


            string           Folder_name      = gvAttachment.DataKeys[e.Row.RowIndex].Values[0].ToString();
            DataTable        dt               = objCP.Get_OwnerAccess(GetSessionUserID(), Folder_name).Tables[0];
            DataTable        dt1              = objCP.Get_OwnerAccess(GetSessionUserID(), Folder_name).Tables[1];
            ImageButton      imgEdit          = (ImageButton)e.Row.FindControl("imgEdit");
            DataControlField dataControlField = gvAttachment.Columns.Cast <DataControlField>().SingleOrDefault(x => x.HeaderText == "Edit");
            if (dt.Rows.Count > 0)
            {
                //dataControlField.Visible = true;
                imgEdit.Visible = true;
            }
            else
            {
                // dataControlField.Visible = false;
                imgEdit.Visible = false;
            }
        }
    }